mGUI: Fix crash if last loaded ROM directory disappears (fixes #1466)

This commit is contained in:
Vicki Pfau 2019-06-24 13:15:37 -07:00
parent 51e7070302
commit ba547b26d1
2 changed files with 7 additions and 2 deletions

View File

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

View File

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