From 347fc3e00db57fc57d76667755ab5976ad1373ac Mon Sep 17 00:00:00 2001 From: Chris Cannam Date: Tue, 25 Jan 2022 13:29:23 +0000 Subject: [PATCH] Ensure we don't overrun the mid-side preprocessing buffer --- src/StretcherProcess.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/StretcherProcess.cpp b/src/StretcherProcess.cpp index acdd035..edc18c9 100644 --- a/src/StretcherProcess.cpp +++ b/src/StretcherProcess.cpp @@ -197,6 +197,15 @@ RubberBandStretcher::Impl::consumeChannel(size_t c, if (samples == 0) return 0; } + if (useMidSide) { + // Our pre-resample buffer size is also constrained by a + // buffer (cd.ms) of the same size as cd.inbuf + size_t ibsz = cd.inbuf->getSize(); + if (ibsz < samples) { + samples = ibsz; + } + } + size_t reqSize = int(ceil(samples / m_pitchScale)); if (reqSize > cd.resamplebufSize) { cerr << "WARNING: RubberBandStretcher::Impl::consumeChannel: resizing resampler buffer from "