Skip to content

Commit

Permalink
tr2/option: fix crash in audio option
Browse files Browse the repository at this point in the history
Resolves #2057.
  • Loading branch information
rr- committed Dec 17, 2024
1 parent 8642283 commit 2449dda
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/tr2/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
5 changes: 3 additions & 2 deletions src/tr2/game/gameflow/reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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) {
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/tr2/game/option/option_sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 2449dda

Please sign in to comment.