GB, GBA Core: Fix memory leak if reloading debug symbols

Also fix loading an ELF if the current seek is not 0
This commit is contained in:
Vicki Pfau 2024-07-07 11:03:06 -07:00
parent ee2533831d
commit 2c2eab2b94
3 changed files with 14 additions and 2 deletions

View File

@ -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

View File

@ -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);

View File

@ -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);
}
}