Skip to content

Commit

Permalink
fix a bug that causes a crash if saving to HDD for the first time
Browse files Browse the repository at this point in the history
  • Loading branch information
KrahJohlito authored and Tupakaveli committed Dec 9, 2019
1 parent 2bd249a commit cbfab5e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,17 @@ char *configGetDir(void)
void configPrepareNotifications(char *prefix)
{
int mcID;
char *colpos;

snprintf(cfgDevice, sizeof(cfgDevice), prefix);
if (!strncmp(cfgDevice, "mc?", 3)) {
mcID = getmcID();
cfgDevice[2] = mcID;
}

if ((colpos = strchr(cfgDevice, ':')) != NULL)
*(colpos + 1) = '\0';

showCfgPopup = 1;
}

Expand Down Expand Up @@ -206,6 +210,8 @@ void configSetMove(char *prefix)
snprintf(path, sizeof(path), "%s/%s", prefix, configFilenames[i]);
configMove(&configFiles[i], path);
}

configPrepareNotifications(prefix);
}

void configEnd()
Expand Down
2 changes: 1 addition & 1 deletion src/guigame.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static char altStartup[32];
static char vmc1[32];
static char vmc2[32];
static char hexDiscID[15];
static char configSource[32];
static char configSource[128];

// forward declarations.
static void guiGameLoadGSMConfig(config_set_t *configSet, config_set_t *configGame);
Expand Down
5 changes: 1 addition & 4 deletions src/opl.c
Original file line number Diff line number Diff line change
Expand Up @@ -957,8 +957,7 @@ int loadConfig(int types)

int saveConfig(int types, int showUI)
{
char notification[32];
char *col_pos;
char notification[128];
lscstatus = types;
lscret = 0;

Expand All @@ -971,8 +970,6 @@ int saveConfig(int types, int showUI)
checkMCFolder();

snprintf(notification, sizeof(notification), _l(_STR_SETTINGS_SAVED), path);
if ((col_pos = strchr(notification, ':')) != NULL)
*(col_pos + 1) = '\0';

guiMsgBox(notification, 0, NULL);
}
Expand Down

0 comments on commit cbfab5e

Please sign in to comment.