diff --git a/CHANGES b/CHANGES index a2b844363..4aad6498f 100644 --- a/CHANGES +++ b/CHANGES @@ -39,6 +39,7 @@ Other fixes: - GB SIO: Fix lockstep failing games aren't reloaded - Core: Fix crash when exiting game with cheats loaded - GBA Cheats: Fix PARv3 Thumb hooks + - mGUI: Fix crash if last loaded ROM directory disappears (fixes mgba.io/i/1466) Misc: - GBA Savedata: EEPROM performance fixes - GBA Savedata: Automatically map 1Mbit Flash files as 1Mbit Flash diff --git a/src/feature/gui/gui-runner.c b/src/feature/gui/gui-runner.c index 038d30a3c..af6584ee0 100644 --- a/src/feature/gui/gui-runner.c +++ b/src/feature/gui/gui-runner.c @@ -212,8 +212,12 @@ void mGUIInit(struct mGUIRunner* runner, const char* port) { const char* lastPath = mCoreConfigGetValue(&runner->config, "lastDirectory"); if (lastPath) { - strncpy(runner->params.currentPath, lastPath, PATH_MAX - 1); - runner->params.currentPath[PATH_MAX - 1] = '\0'; + struct VDir* dir = VDirOpen(lastPath); + if (dir) { + dir->close(dir); + strncpy(runner->params.currentPath, lastPath, PATH_MAX - 1); + runner->params.currentPath[PATH_MAX - 1] = '\0'; + } } #ifndef DISABLE_THREADING