GB: Fix crash when patching ROM
Vicki Pfau vi@endrift.com
Wed, 01 Feb 2017 13:47:03 -0800
2 files changed,
5 insertions(+),
0 deletions(-)
M
CHANGES
→
CHANGES
@@ -8,6 +8,7 @@ - GB MBC: Fix ROM bank overflows getting set to bank 0
- Qt: Fix timing issues on high refresh rate monitors - GBA Savedata: Fix savedata unmasking (fixes mgba.io/i/441) - Util: Fix overflow when loading invalid UPS patches + - GB: Fix crash when patching ROMs Misc: - Qt: Improved HiDPI support - Feature: Support ImageMagick 7
M
src/gb/gb.c
→
src/gb/gb.c
@@ -285,11 +285,15 @@ }
if (patchedSize > GB_SIZE_CART_MAX) { patchedSize = GB_SIZE_CART_MAX; } + void* oldRom = gb->memory.rom; gb->memory.rom = anonymousMemoryMap(GB_SIZE_CART_MAX); if (!patch->applyPatch(patch, gb->pristineRom, gb->pristineRomSize, gb->memory.rom, patchedSize)) { mappedMemoryFree(gb->memory.rom, patchedSize); gb->memory.rom = gb->pristineRom; return; + } + if (gb->memory.romBase == oldRom) { + gb->memory.romBase = gb->memory.rom; } gb->memory.romSize = patchedSize; gb->romCrc32 = doCrc32(gb->memory.rom, gb->memory.romSize);