From a0bcc9dd836337843f30e58604d33bb4751f07e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Sun, 20 Aug 2023 18:53:16 +0200 Subject: [PATCH] LibAudio: Skip empty MP3 scale factor bands in stereo intensity process MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These were intentionally set up to be at the end of the granule size, but since the stereo intensity loop is intentionally using a <= end comparison (that’s how the scale factor bands work), we must skip these dummy bands which would otherwise cause an out-of-bounds index. --- Userland/Libraries/LibAudio/MP3Loader.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Userland/Libraries/LibAudio/MP3Loader.cpp b/Userland/Libraries/LibAudio/MP3Loader.cpp index 56926dda29..9cf321d5f5 100644 --- a/Userland/Libraries/LibAudio/MP3Loader.cpp +++ b/Userland/Libraries/LibAudio/MP3Loader.cpp @@ -724,6 +724,9 @@ void MP3LoaderPlugin::process_stereo(MP3::MP3Frame& frame, size_t granule_index) auto process_intensity_stereo = [&](MP3::Tables::ScaleFactorBand const& band, float intensity_stereo_ratio) { for (size_t i = band.start; i <= band.end; i++) { + // Superflous empty scale factor band. + if (i >= MP3::granule_size) + continue; float const sample_left = granule_left.samples[i]; float const coeff_l = intensity_stereo_ratio / (1 + intensity_stereo_ratio); float const coeff_r = 1 / (1 + intensity_stereo_ratio);