all repos — mgba @ 3a834d564daeee9f3b1671efcef3b189e3d9aab5

mGBA Game Boy Advance Emulator

Core: Fix some memory leaks
Jeffrey Pfau jeffrey@endrift.com
Wed, 07 Sep 2016 11:04:31 -0700
commit

3a834d564daeee9f3b1671efcef3b189e3d9aab5

parent

f7a9fe8e64c3d537e3d3342d06ed7e096d20b33b

5 files changed, 11 insertions(+), 3 deletions(-)

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

@@ -74,6 +74,7 @@ if (gbcore->cheatDevice) {

mCheatDeviceDestroy(gbcore->cheatDevice); } free(gbcore->cheatDevice); + mCoreConfigFreeOpts(&core->opts); free(core); }
M src/gb/gb.csrc/gb/gb.c

@@ -221,6 +221,11 @@

void GBDestroy(struct GB* gb) { GBUnloadROM(gb); + if (gb->biosVf) { + gb->biosVf->close(gb->biosVf); + gb->biosVf = 0; + } + GBMemoryDeinit(gb); GBVideoDeinit(&gb->video); GBSIODeinit(&gb->sio);
M src/gba/core.csrc/gba/core.c

@@ -92,6 +92,7 @@ if (gbacore->cheatDevice) {

mCheatDeviceDestroy(gbacore->cheatDevice); } free(gbacore->cheatDevice); + mCoreConfigFreeOpts(&core->opts); free(core); }
M src/gba/gba.csrc/gba/gba.c

@@ -140,6 +140,8 @@ GBAUnloadROM(gba);

if (gba->biosVf) { gba->biosVf->unmap(gba->biosVf, gba->memory.bios, SIZE_BIOS); + gba->biosVf->close(gba->biosVf); + gba->biosVf = 0; } GBAMemoryDeinit(gba);
M src/platform/qt/GameController.cppsrc/platform/qt/GameController.cpp

@@ -406,9 +406,8 @@ m_threadContext.core->setVideoBuffer(m_threadContext.core, m_drawContext, width);

if (!m_bios.isNull() && m_useBios) { VFile* bios = VFileDevice::open(m_bios, O_RDONLY); - if (bios) { - // TODO: Lifetime issues? - m_threadContext.core->loadBIOS(m_threadContext.core, bios, 0); + if (bios && !m_threadContext.core->loadBIOS(m_threadContext.core, bios, 0)) { + bios->close(bios); } }