From ebc1092c4c0769853d0c0d92287398f480a06c8f Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sat, 6 Jan 2018 18:22:12 -0500 Subject: [PATCH] One of the compilation warning patches in f463eda36c059 made a bug... ... the variable bin may indeed be sometimes negative: see the test that follows. --- src/WaveClip.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/WaveClip.cpp b/src/WaveClip.cpp index 48a25cebe..a6ee5d5bf 100644 --- a/src/WaveClip.cpp +++ b/src/WaveClip.cpp @@ -984,8 +984,10 @@ bool SpecCache::CalculateOneSpectrum freqCorrection = multiplier * quotIm; } - const size_t bin = (size_t)(ii + freqCorrection + 0.5f); - if (bin >= 0 && bin < hFFT->Points) { + const int bin = (int)((int)ii + freqCorrection + 0.5f); + // Must check if correction takes bin out of bounds, above or below! + // bin is signed! + if (bin >= 0 && bin < (int)hFFT->Points) { double timeCorrection; { const float