Core: Fix directory sets crashing on close if base isn't properly detached
Vicki Pfau vi@endrift.com
Thu, 29 Jun 2017 18:17:21 -0700
2 files changed,
41 insertions(+),
10 deletions(-)
M
CHANGES
→
CHANGES
@@ -74,6 +74,7 @@ - OpenGL: Fix some shaders causing offset graphics
- Qt: Fix game unpausing after frame advancing and refocusing - GB Timer: Fix sub-M-cycle DIV reset timing and edge triggering - Core: Fix interrupting a thread while on the thread (fixes mgba.io/i/692) + - Core: Fix directory sets crashing on close if base isn't properly detached Misc: - SDL: Remove scancode key input - GBA Video: Clean up unused timers
M
src/core/directories.c
→
src/core/directories.c
@@ -22,28 +22,58 @@ void mDirectorySetDeinit(struct mDirectorySet* dirs) {
mDirectorySetDetachBase(dirs); if (dirs->archive) { + if (dirs->archive == dirs->save) { + dirs->save = NULL; + } + if (dirs->archive == dirs->patch) { + dirs->patch = NULL; + } + if (dirs->archive == dirs->state) { + dirs->state = NULL; + } + if (dirs->archive == dirs->screenshot) { + dirs->screenshot = NULL; + } dirs->archive->close(dirs->archive); - dirs->archive = 0; + dirs->archive = NULL; } if (dirs->save) { + if (dirs->save == dirs->patch) { + dirs->patch = NULL; + } + if (dirs->save == dirs->state) { + dirs->state = NULL; + } + if (dirs->save == dirs->screenshot) { + dirs->screenshot = NULL; + } dirs->save->close(dirs->save); - dirs->save = 0; + dirs->save = NULL; } if (dirs->patch) { + if (dirs->patch == dirs->state) { + dirs->state = NULL; + } + if (dirs->patch == dirs->screenshot) { + dirs->screenshot = NULL; + } dirs->patch->close(dirs->patch); - dirs->patch = 0; + dirs->patch = NULL; } if (dirs->state) { + if (dirs->state == dirs->screenshot) { + dirs->state = NULL; + } dirs->state->close(dirs->state); - dirs->state = 0; + dirs->state = NULL; } if (dirs->screenshot) { dirs->screenshot->close(dirs->screenshot); - dirs->screenshot = 0; + dirs->screenshot = NULL; } }@@ -65,21 +95,21 @@ }
void mDirectorySetDetachBase(struct mDirectorySet* dirs) { if (dirs->save == dirs->base) { - dirs->save = 0; + dirs->save = NULL; } if (dirs->patch == dirs->base) { - dirs->patch = 0; + dirs->patch = NULL; } if (dirs->state == dirs->base) { - dirs->state = 0; + dirs->state = NULL; } if (dirs->screenshot == dirs->base) { - dirs->screenshot = 0; + dirs->screenshot = NULL; } if (dirs->base) { dirs->base->close(dirs->base); - dirs->base = 0; + dirs->base = NULL; } }