From 24145950636297b73db7d117793953b5d4fef5e9 Mon Sep 17 00:00:00 2001 From: sukibaby <163092272+sukibaby@users.noreply.github.com> Date: Fri, 21 Feb 2025 05:20:26 -0800 Subject: [PATCH] do_mad_frame_decode might return 0, protect against possible crash In the song wheel, if you scroll back and forth over an MP3 song very fast, you might get some audible corruption at the beginning of the song preview, and it might even crash the game. This fixes both of those problems. --- src/RageSoundReader_MP3.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/RageSoundReader_MP3.cpp b/src/RageSoundReader_MP3.cpp index cbe5253745..ce31400062 100644 --- a/src/RageSoundReader_MP3.cpp +++ b/src/RageSoundReader_MP3.cpp @@ -785,8 +785,14 @@ int RageSoundReader_MP3::SetPosition_hard( int iFrame ) /* If we're already past the requested position, rewind. */ if(mad_timer_compare(mad->Timer, desired) > 0) { - MADLIB_rewind(); - do_mad_frame_decode(); + if (!MADLIB_rewind()) + { + return -1; + } + if (do_mad_frame_decode() <= 0) + { + return -1; + } synthed = false; }