diff --git a/os2.c b/os2.c index 3b6c48e2c0..8d41f194b5 100644 --- a/os2.c +++ b/os2.c @@ -210,9 +210,10 @@ FiosItem *FiosGetScenarioList(int *num, int mode) int sort_start; char filename[MAX_PATH]; - if (_fios_scn_path == NULL) { - _fios_scn_path = malloc(MAX_PATH); - strcpy(_fios_scn_path, _path.scenario_dir); + /* Copy the default path on first run or on 'New Game' */ + if (mode == SLD_NEW_GAME || _fios_scn_path == NULL) { + if (_fios_scn_path == NULL) _fios_scn_path = malloc(MAX_PATH); + ttd_strlcpy(_fios_scn_path, _path.scenario_dir, MAX_PATH); } _fios_path = _fios_scn_path; diff --git a/unix.c b/unix.c index dff6cdc361..3d2faed53f 100644 --- a/unix.c +++ b/unix.c @@ -208,9 +208,10 @@ FiosItem *FiosGetScenarioList(int *num, int mode) int sort_start; char filename[MAX_PATH]; - if (_fios_scn_path == NULL) { - _fios_scn_path = malloc(MAX_PATH); - strcpy(_fios_scn_path, _path.scenario_dir); + /* Copy the default path on first run or on 'New Game' */ + if (mode == SLD_NEW_GAME || _fios_scn_path == NULL) { + if (_fios_scn_path == NULL) _fios_scn_path = malloc(MAX_PATH); + ttd_strlcpy(_fios_scn_path, _path.scenario_dir, MAX_PATH); } _fios_path = _fios_scn_path; diff --git a/win32.c b/win32.c index 9f08d7d34a..a3c4dad790 100644 --- a/win32.c +++ b/win32.c @@ -779,9 +779,10 @@ FiosItem *FiosGetScenarioList(int *num, int mode) HANDLE h; int sort_start; - if (_fios_scn_path == NULL) { - _fios_scn_path = malloc(MAX_PATH); - strcpy(_fios_scn_path, _path.scenario_dir); + /* Copy the default path on first run or on 'New Game' */ + if (mode == SLD_NEW_GAME || _fios_scn_path == NULL) { + if (_fios_scn_path == NULL) _fios_scn_path = malloc(MAX_PATH); + ttd_strlcpy(_fios_scn_path, _path.scenario_dir, MAX_PATH); } _fios_path = _fios_scn_path;