From 5fe3b9d0dedfcf34cbcd782ba87f01b2f2e87d99 Mon Sep 17 00:00:00 2001 From: Misa Date: Tue, 30 Jun 2020 17:17:29 -0700 Subject: [PATCH] Add bounds check to musicclass::play() If the song number (after we've processed it) is out-of-bounds, then just return and log the error. --- desktop_version/src/Music.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/desktop_version/src/Music.cpp b/desktop_version/src/Music.cpp index 69b348d0..ce29c5c7 100644 --- a/desktop_version/src/Music.cpp +++ b/desktop_version/src/Music.cpp @@ -163,6 +163,12 @@ void musicclass::play(int t, const double position_sec /*= 0.0*/, const int fade if (t != -1) { currentsong = t; + if (!INBOUNDS(t, musicTracks)) + { + puts("play() out-of-bounds!"); + currentsong = -1; + return; + } if (currentsong == 0 || currentsong == 7 || (!map.custommode && (currentsong == 0+num_pppppp_tracks || currentsong == 7+num_pppppp_tracks))) { // Level Complete theme, no fade in or repeat