From feec263875299f9766f4d0107b878f17997178d1 Mon Sep 17 00:00:00 2001 From: essej Date: Mon, 25 Apr 2022 19:34:30 -0400 Subject: [PATCH] fixed buffer overflow issue with large channel counts, found from au validation fail --- Source/PS_Source/StretchSource.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Source/PS_Source/StretchSource.cpp b/Source/PS_Source/StretchSource.cpp index 4107460..f044cc2 100644 --- a/Source/PS_Source/StretchSource.cpp +++ b/Source/PS_Source/StretchSource.cpp @@ -313,10 +313,10 @@ void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & buffer if (m_vol_smoother.getTargetValue() != maingain) - m_vol_smoother.setValue(maingain); + m_vol_smoother.setTargetValue(maingain); FloatVectorOperations::disableDenormalisedNumberSupport(); float** outarrays = bufferToFill.buffer->getArrayOfWritePointers(); - int outbufchans = m_num_outchans; // bufferToFill.buffer->getNumChannels(); + int outbufchans = jmin(m_num_outchans, bufferToFill.buffer->getNumChannels()); int offset = bufferToFill.startSample; if (m_stretchers.size() == 0) return; @@ -430,7 +430,7 @@ void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & buffer m_xfadetask.state = 2; } }; - + resamplertask(); if (previousxfadestate == 1 && m_xfadetask.state == 2) { @@ -547,6 +547,10 @@ void StretchAudioSource::initObjects() //Logger::writeToLog("Resizing circular buffer to " + String(newsize)); m_stretchoutringbuf.resize(newsize); } + if (m_xfadetask.buffer.getNumChannels() < m_num_outchans) + { + m_xfadetask.buffer.setSize(m_num_outchans, m_xfadetask.buffer.getNumSamples()); + } m_stretchoutringbuf.clear(); m_resampler->Reset(); m_resampler->SetRates(m_inputfile->info.samplerate, m_outsr);