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 f394c51a75
commit bdffa83e6b
3 changed files with 14 additions and 2 deletions

View File

@ -23,6 +23,7 @@ Other fixes:
- Core: Fix inconsistencies with setting game-specific overrides (fixes mgba.io/i/2963)
- Debugger: Fix writing to specific segment in command-line debugger
- GB: Fix uninitialized save data when loading undersized temporary saves
- 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

@ -1107,7 +1107,9 @@ static void _GBCoreDetachDebugger(struct mCore* core) {
}
static void _GBCoreLoadSymbols(struct mCore* core, struct VFile* vf) {
if (!core->symbolTable) {
core->symbolTable = mDebuggerSymbolTableCreate();
}
#ifdef ENABLE_VFS
if (!vf && core->dirs.base) {
vf = mDirectorySetOpenSuffix(&core->dirs, core->dirs.base, ".sym", O_RDONLY);

View File

@ -1243,7 +1243,14 @@ static void _GBACoreDetachDebugger(struct mCore* core) {
static void _GBACoreLoadSymbols(struct mCore* core, struct VFile* vf) {
bool closeAfter = false;
if (!core->symbolTable) {
core->symbolTable = mDebuggerSymbolTableCreate();
}
off_t seek;
if (vf) {
seek = vf->seek(vf, 0, SEEK_CUR);
vf->seek(vf, 0, SEEK_SET);
}
#ifdef ENABLE_VFS
#ifdef USE_ELF
if (!vf && core->dirs.base) {
@ -1273,6 +1280,8 @@ static void _GBACoreLoadSymbols(struct mCore* core, struct VFile* vf) {
}
if (closeAfter) {
vf->close(vf);
} else {
vf->seek(vf, seek, SEEK_SET);
}
}