From 8c70c9eb978ffd137556114e46da3f000ae807d1 Mon Sep 17 00:00:00 2001 From: NyakoFox Date: Thu, 14 May 2026 19:09:17 -0300 Subject: [PATCH] Set `id` and `loose_extra` fields no matter what The PR #1278 seems to have introduced a segfault. When an empty music track is found, it skips past `id` (and `loose_extra`) being set. Functions which use `id` expect a string, not NULL, causing a crash whenever `isextra` is called, which happens to be every time the `music` or `play` commands are invoked. This fix simply moves the setting of these variables upwards, BEFORE the valid check, to make sure they're always set. --- desktop_version/src/Music.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/desktop_version/src/Music.cpp b/desktop_version/src/Music.cpp index bc7f87a1..a55310c9 100644 --- a/desktop_version/src/Music.cpp +++ b/desktop_version/src/Music.cpp @@ -381,6 +381,10 @@ public: MusicTrack(SDL_RWops *rw, const char* _id, bool _loose_extra) { SDL_zerop(this); + + id = SDL_strdup(_id); + loose_extra = _loose_extra; + if (rw->size(rw) <= 1) { // Don't bother @@ -393,9 +397,6 @@ public: stb_vorbis_info vorbis_info; stb_vorbis_comment vorbis_comment; - id = SDL_strdup(_id); - - loose_extra = _loose_extra; vorbis = stb_vorbis_open_memory(read_buf, rw->size(rw), &err, NULL); if (vorbis == NULL) {