all repos — mgba @ 39203a0dafcb93542227e86b86229d7ad7ac7f00

mGBA Game Boy Advance Emulator

GBA: Fix leak if attempting to load BIOS multiple times
Vicki Pfau vi@endrift.com
Mon, 20 Jul 2020 09:19:46 -0700
commit

39203a0dafcb93542227e86b86229d7ad7ac7f00

parent

5b319cfd91fff2fcd3df0e1fce3e498454796da0

2 files changed, 6 insertions(+), 1 deletions(-)

jump to
M CHANGESCHANGES

@@ -39,6 +39,7 @@ - Debugger: Don't skip undefined instructions when debugger attached

- FFmpeg: Fix some small memory leaks - FFmpeg: Fix encoding of time base - GB Core: Fix extracting SRAM when none is present + - GBA: Fix leak if attempting to load BIOS multiple times - GBA Savedata: Fix extracting save when not yet configured in-game - Qt: Force OpenGL paint engine creation thread (fixes mgba.io/i/1642) - Qt: Fix static compilation in MinGW (fixes mgba.io/i/1769)
M src/gba/gba.csrc/gba/gba.c

@@ -443,7 +443,6 @@ GBARaiseIRQ(gba, IRQ_GAMEPAK, 0);

} void GBALoadBIOS(struct GBA* gba, struct VFile* vf) { - gba->biosVf = vf; if (vf->size(vf) != SIZE_BIOS) { mLOG(GBA, WARN, "Incorrect BIOS size"); return;

@@ -453,6 +452,11 @@ if (!bios) {

mLOG(GBA, WARN, "Couldn't map BIOS"); return; } + if (gba->biosVf) { + gba->biosVf->unmap(gba->biosVf, gba->memory.bios, SIZE_BIOS); + gba->biosVf->close(gba->biosVf); + } + gba->biosVf = vf; gba->memory.bios = bios; gba->memory.fullBios = 1; uint32_t checksum = GBAChecksum(gba->memory.bios, SIZE_BIOS);