From a0f3b6c184d63153f5981d0b55f68f8242ddfc5f Mon Sep 17 00:00:00 2001 From: leso-kn Date: Wed, 9 Apr 2025 12:54:21 +0200 Subject: [PATCH] Fix crash in Voice::Impl::fillInterpolated() Recent versions of abseil assert on possible buffer overflow --- src/sfizz/Voice.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sfizz/Voice.cpp b/src/sfizz/Voice.cpp index e5233aacd..681b6ea5f 100644 --- a/src/sfizz/Voice.cpp +++ b/src/sfizz/Voice.cpp @@ -1369,6 +1369,8 @@ void Voice::Impl::fillInterpolated( auto left = dest.getChannel(0); if (source.getNumChannels() == 1) { while (ind < indices.end()) { + if ((size_t)*ind >= leftSource.size()) + break; auto output = interpolate(&leftSource[*ind], *coeff); IF_CONSTEXPR(Adding) { float g = *addingGain++; @@ -1382,6 +1384,8 @@ void Voice::Impl::fillInterpolated( auto right = dest.getChannel(1); auto rightSource = source.getConstSpan(1); while (ind < indices.end()) { + if ((size_t)*ind >= leftSource.size() || (size_t)*ind >= rightSource.size()) + break; auto leftOutput = interpolate(&leftSource[*ind], *coeff); auto rightOutput = interpolate(&rightSource[*ind], *coeff); IF_CONSTEXPR(Adding) {