diff --git a/CHANGES b/CHANGES index 5aa3abebd..d1795582b 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,7 @@ Emulation fixes: - GBA GPIO: Fix gyro read-out start (fixes mgba.io/i/3141) - GBA SIO: Fix MULTI mode SIOCNT bit 7 writes on secondary GBAs (fixes mgba.io/i/3110) Other fixes: + - GB, GBA Core: Fix memory leak if reloading debug symbols - GBA Audio: Fix crash if audio FIFOs and timers get out of sync - GBA Audio: Fix crash in audio subsampling if timing lockstep breaks - GBA Memory: Let raw access read high MMIO addresses diff --git a/src/gb/core.c b/src/gb/core.c index c5569979b..8c2b087ae 100644 --- a/src/gb/core.c +++ b/src/gb/core.c @@ -1050,7 +1050,9 @@ static void _GBCoreDetachDebugger(struct mCore* core) { } static void _GBCoreLoadSymbols(struct mCore* core, struct VFile* vf) { - core->symbolTable = mDebuggerSymbolTableCreate(); + if (!core->symbolTable) { + core->symbolTable = mDebuggerSymbolTableCreate(); + } #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 if (!vf && core->dirs.base) { vf = mDirectorySetOpenSuffix(&core->dirs, core->dirs.base, ".sym", O_RDONLY); diff --git a/src/gba/core.c b/src/gba/core.c index c67bab304..cbe85e10f 100644 --- a/src/gba/core.c +++ b/src/gba/core.c @@ -1113,7 +1113,14 @@ static void _GBACoreDetachDebugger(struct mCore* core) { static void _GBACoreLoadSymbols(struct mCore* core, struct VFile* vf) { bool closeAfter = false; - core->symbolTable = mDebuggerSymbolTableCreate(); + if (!core->symbolTable) { + core->symbolTable = mDebuggerSymbolTableCreate(); + } + off_t seek; + if (vf) { + seek = vf->seek(vf, 0, SEEK_CUR); + vf->seek(vf, 0, SEEK_SET); + } #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 #ifdef USE_ELF if (!vf && core->dirs.base) { @@ -1143,6 +1150,8 @@ static void _GBACoreLoadSymbols(struct mCore* core, struct VFile* vf) { } if (closeAfter) { vf->close(vf); + } else { + vf->seek(vf, seek, SEEK_SET); } }