# HG changeset patch # User Michael Pavone # Date 1438749800 25200 # Node ID e6f2c9dbf6c882f3e42e6db36a16530c356707a7 # Parent 3b8267fd1687c2cecf43e40d08126267ee682679 Prevent crashes if game tries to access the ROM area outside of the size of the actual ROM diff -r 3b8267fd1687 -r e6f2c9dbf6c8 romdb.c --- a/romdb.c Mon Aug 03 22:31:13 2015 -0700 +++ b/romdb.c Tue Aug 04 21:43:20 2015 -0700 @@ -493,7 +493,7 @@ 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 @@ 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;