all repos — mgba @ c2de079a9d08982c2d8a66b7f6105b8ae3e05094

mGBA Game Boy Advance Emulator

GB: Properly unmap ROM base when unloading ROM
Vicki Pfau vi@endrift.com
Mon, 22 Mar 2021 23:48:19 -0700
commit

c2de079a9d08982c2d8a66b7f6105b8ae3e05094

parent

2fc5e2d08d6d5bcc6fef28d2a740f6b2b56eeb38

1 files changed, 4 insertions(+), 0 deletions(-)

jump to
M src/gb/gb.csrc/gb/gb.c

@@ -293,6 +293,10 @@ }

void GBUnloadROM(struct GB* gb) { // TODO: Share with GBAUnloadROM + off_t romBase = gb->memory.romBase - gb->memory.rom; + if (romBase >= 0 && ((size_t) romBase < gb->memory.romSize || (size_t) romBase < gb->yankedRomSize)) { + gb->memory.romBase = NULL; + } if (gb->memory.rom && !gb->isPristine) { if (gb->yankedRomSize) { gb->yankedRomSize = 0;