all repos — mgba @ aa9a8d14307efceeadb9dff76cd285acfb087ef6

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

aa9a8d14307efceeadb9dff76cd285acfb087ef6

parent

a59ccd2d24627a10006c130fe352352af65f51e4

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

jump to
M CHANGESCHANGES

@@ -15,6 +15,7 @@ - All: Correct format strings for some numbers on Windows (fixes mgba.io/i/1794)

- All: Correct more format strings on Windows (fixes mgba.io/i/1817) - CMake: Fix build with libzip 1.7 - 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: Fix file handle leak on opening an invalid ROM - Qt: Fix Italian RTC translation (fixes mgba.io/i/1798)
M src/gba/gba.csrc/gba/gba.c

@@ -444,7 +444,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;

@@ -454,6 +453,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);