From 876362365b298225bc6580c2d32867813267276e Mon Sep 17 00:00:00 2001 From: Misa Date: Sun, 13 Nov 2022 19:47:37 -0800 Subject: [PATCH] Ignore comments of tracks with a negative loop comment If a music track has a loop comment with a negative value, ignore all comments of the track. This is just to prevent any weirdness from happening as it's safer to just let the track loop improperly. Also log to the console to let users know. This is the same thing that SDL_mixer does now: libsdl-org/SDL_mixer@e819489459d5e9942851b9547854ba988fe50291 This commit happened as a result of discussion on the VVVVVV Discord server about SDL_mixer 2.0.4 behavior with weird loop comment values (e.g. octal input with leading zeroes). This is simply updating the code to be in line with what newer versions of SDL_mixer do. --- desktop_version/src/Music.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/desktop_version/src/Music.cpp b/desktop_version/src/Music.cpp index 6aa16757..3e52c667 100644 --- a/desktop_version/src/Music.cpp +++ b/desktop_version/src/Music.cpp @@ -526,6 +526,19 @@ end: loopend = _Mix_ParseTime(value, t->format.nSamplesPerSec); } + if (t->loopbegin < 0 || t->looplength < 0 || loopend < 0) + { + vlog_warn( + "A track loop comment had a negative value. " + "Ignoring all comments for the track." + ); + t->loopbegin = 0; + t->looplength = 0; + loopend = 0; + SDL_free(param); + break; + } + SDL_free(param); } if (loopend != 0)