From 26c0c8a21162f60b15e29821bcd98834b9455ec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 22 Nov 2024 08:21:21 +0100 Subject: [PATCH] Fix read before m_bufferInt during scratching --- src/engine/bufferscalers/enginebufferscalelinear.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine/bufferscalers/enginebufferscalelinear.cpp b/src/engine/bufferscalers/enginebufferscalelinear.cpp index a461dd21cb6..55f2f804510 100644 --- a/src/engine/bufferscalers/enginebufferscalelinear.cpp +++ b/src/engine/bufferscalers/enginebufferscalelinear.cpp @@ -85,9 +85,12 @@ double EngineBufferScaleLinear::scaleBuffer( // reset m_floorSampleOld in a way as we were coming from // the other direction SINT iNextSample = getOutputSignal().frames2samples(static_cast(ceil(m_dNextFrame))); - if (iNextSample + 1 < m_bufferIntSize) { + if (iNextSample >= 0 && iNextSample + 1 < m_bufferIntSize) { m_floorSampleOld[0] = m_bufferInt[iNextSample]; m_floorSampleOld[1] = m_bufferInt[iNextSample + 1]; + } else { + m_floorSampleOld[0] = CSAMPLE_ZERO; + m_floorSampleOld[1] = CSAMPLE_ZERO; } // if the buffer has extra samples, do a read so RAMAN ends up back where