tr2/shell: fix crash when exiting with -l

This commit is contained in:
Marcin Kurczewski 2025-03-11 20:11:43 +01:00
parent 655bd311fb
commit 92837a07c9
2 changed files with 6 additions and 5 deletions

View file

@ -98,11 +98,7 @@ typedef struct {
typedef struct { typedef struct {
int32_t num; int32_t num;
GF_LEVEL_TYPE type; GF_LEVEL_TYPE type;
#if TR_VERSION == 1
char *path; char *path;
#elif TR_VERSION == 2
const char *path;
#endif
char *title; char *title;
MUSIC_TRACK_ID music_track; MUSIC_TRACK_ID music_track;

View file

@ -393,7 +393,9 @@ void Shell_Main(void)
GameBuf_Init(); GameBuf_Init();
if (level_to_play != nullptr) { if (level_to_play != nullptr) {
g_GameFlow.level_tables[GFLT_MAIN].levels[0].path = level_to_play; Memory_Free(g_GameFlow.level_tables[GFLT_MAIN].levels[0].path);
g_GameFlow.level_tables[GFLT_MAIN].levels[0].path =
Memory_DupStr(level_to_play);
} }
GF_COMMAND gf_cmd = level_to_play != nullptr GF_COMMAND gf_cmd = level_to_play != nullptr
@ -468,6 +470,9 @@ void Shell_Main(void)
} }
Config_Write(); Config_Write();
if (level_to_play != nullptr) {
Memory_FreePointer(&g_GameFlow.level_tables[GFLT_MAIN].levels[0].path);
}
} }
void Shell_Shutdown(void) void Shell_Shutdown(void)