diff --git a/docs/tr2/CHANGELOG.md b/docs/tr2/CHANGELOG.md index 186f1d656..e64c59999 100644 --- a/docs/tr2/CHANGELOG.md +++ b/docs/tr2/CHANGELOG.md @@ -1,4 +1,5 @@ ## [Unreleased](https://github.com/LostArtefacts/TRX/compare/tr2-0.7...develop) - ××××-××-×× +- fixed a crash when selecting the sound option (#2057, regression from 0.6) ## [0.7](https://github.com/LostArtefacts/TRX/compare/tr2-0.6...tr2-0.7) - 2024-12-16 - switched to OpenGL rendering (#1844) diff --git a/src/tr2/game/gameflow/reader.c b/src/tr2/game/gameflow/reader.c index ec7d0e7f2..e069b4745 100644 --- a/src/tr2/game/gameflow/reader.c +++ b/src/tr2/game/gameflow/reader.c @@ -182,6 +182,7 @@ bool GF_N_Load(const char *const path) GF_N_Shutdown(); bool result = true; + JSON_VALUE *root = NULL; char *script_data = NULL; if (!File_Load(path, &script_data, NULL)) { @@ -191,7 +192,7 @@ bool GF_N_Load(const char *const path) } JSON_PARSE_RESULT parse_result; - JSON_VALUE *root = JSON_ParseEx( + root = JSON_ParseEx( script_data, strlen(script_data), JSON_PARSE_FLAGS_ALLOW_JSON5, NULL, NULL, &parse_result); if (root == NULL) { @@ -212,7 +213,7 @@ bool GF_N_Load(const char *const path) result &= M_LoadScriptLevels(root_obj, gf); end: - if (root) { + if (root != NULL) { JSON_ValueFree(root); root = NULL; } diff --git a/src/tr2/game/option/option_sound.c b/src/tr2/game/option/option_sound.c index a502678ab..2c231f3b5 100644 --- a/src/tr2/game/option/option_sound.c +++ b/src/tr2/game/option/option_sound.c @@ -19,7 +19,7 @@ static void M_InitText(void) CLAMPG(g_Config.audio.music_volume, 10); CLAMPG(g_Config.audio.sound_volume, 10); - char text[8]; + char text[32]; sprintf(text, "\\{icon music} %2d", g_Config.audio.music_volume); g_SoundText[0] = Text_Create(0, 0, text); Text_AddBackground(g_SoundText[0], 128, 0, 0, 0, TS_REQUESTED); @@ -57,7 +57,7 @@ void Option_Sound_Shutdown(void) void Option_Sound_Control(INVENTORY_ITEM *const item) { - char text[8]; + char text[32]; if (g_SoundText[0] == NULL) { M_InitText();