Mercurial > repos > blastem
comparison m68k_core.c @ 725:a92ca6f0ed83
Fix out of bounds memory access when an instruction wraps around the end of memory
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 22 May 2015 21:11:41 -0700 |
parents | f9b80a78d9a6 |
children | 7367b14ac01c |
comparison
equal
deleted
inserted
replaced
724:2174f92c5f9b | 725:a92ca6f0ed83 |
---|---|
634 memset(native_code_map[chunk].offsets, 0xFF, sizeof(int32_t) * NATIVE_CHUNK_SIZE); | 634 memset(native_code_map[chunk].offsets, 0xFF, sizeof(int32_t) * NATIVE_CHUNK_SIZE); |
635 } | 635 } |
636 uint32_t offset = address % NATIVE_CHUNK_SIZE; | 636 uint32_t offset = address % NATIVE_CHUNK_SIZE; |
637 native_code_map[chunk].offsets[offset] = native_addr-native_code_map[chunk].base; | 637 native_code_map[chunk].offsets[offset] = native_addr-native_code_map[chunk].base; |
638 for(address++,size-=2; size; address++,size-=2) { | 638 for(address++,size-=2; size; address++,size-=2) { |
639 address &= opts->gen.address_mask >> 1; | |
639 chunk = address / NATIVE_CHUNK_SIZE; | 640 chunk = address / NATIVE_CHUNK_SIZE; |
640 offset = address % NATIVE_CHUNK_SIZE; | 641 offset = address % NATIVE_CHUNK_SIZE; |
641 if (!native_code_map[chunk].base) { | 642 if (!native_code_map[chunk].base) { |
642 native_code_map[chunk].base = native_addr; | 643 native_code_map[chunk].base = native_addr; |
643 native_code_map[chunk].offsets = malloc(sizeof(int32_t) * NATIVE_CHUNK_SIZE); | 644 native_code_map[chunk].offsets = malloc(sizeof(int32_t) * NATIVE_CHUNK_SIZE); |