diff options
author | Michael Pavone <pavone@retrodev.com> | 2015-08-04 21:43:20 -0700 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2015-08-04 21:43:20 -0700 |
commit | 167eb95b3a3d62781ddb8ab4754e0b5d0d8ae6d0 (patch) | |
tree | 8a145b900f2c5d3f4d3e04f1ffcf874adf72e6f7 /romdb.c | |
parent | b23113f80d566e4ab55c6133ebf747af782914d3 (diff) |
Prevent crashes if game tries to access the ROM area outside of the size of the actual ROM
Diffstat (limited to 'romdb.c')
-rw-r--r-- | romdb.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -493,7 +493,7 @@ void add_memmap_header(rom_info *info, uint8_t *rom, uint32_t size, memmap_chunk memcpy(info->map+2, base_map, sizeof(memmap_chunk) * base_chunks); if (ram_start >= rom_end) { - info->map[0].end = rom_end > 0x400000 ? rom_end : 0x400000; + info->map[0].end = rom_end < 0x400000 ? nearest_pow2(rom_end) - 1 : 0xFFFFFF; //TODO: ROM mirroring info->map[0].mask = 0xFFFFFF; info->map[0].flags = MMAP_READ; @@ -542,8 +542,8 @@ void add_memmap_header(rom_info *info, uint8_t *rom, uint32_t size, memmap_chunk memset(info->map, 0, sizeof(memmap_chunk)); memcpy(info->map+1, base_map, sizeof(memmap_chunk) * base_chunks); - info->map[0].end =rom_end > 0x400000 ? rom_end : 0x400000; - info->map[0].mask = 0xFFFFFF; + info->map[0].end = rom_end > 0x400000 ? rom_end : 0x400000; + info->map[0].mask = rom_end < 0x400000 ? nearest_pow2(rom_end) - 1 : 0xFFFFFF; info->map[0].flags = MMAP_READ; info->map[0].buffer = rom; info->save_type = SAVE_NONE; |