all repos — mgba @ 6df55275b864fefa31122004e74d35ddde6885b6

mGBA Game Boy Advance Emulator

GB: Fix crash when patching ROM
Vicki Pfau vi@endrift.com
Wed, 01 Feb 2017 13:47:03 -0800
commit

6df55275b864fefa31122004e74d35ddde6885b6

parent

9959ef857017ec5de709bf6fd732207419469ccf

2 files changed, 5 insertions(+), 0 deletions(-)

jump to
M CHANGESCHANGES

@@ -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.csrc/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);