From e7e11bfb5b9dde59d259eca1438a807277655a0c Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Tue, 10 Jul 2012 15:28:39 -0700 Subject: [PATCH] src/pitch/pitchschmitt.c: avoid out of bound reads --- src/pitch/pitchschmitt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pitch/pitchschmitt.c b/src/pitch/pitchschmitt.c index 6f017619..0c9acbc7 100644 --- a/src/pitch/pitchschmitt.c +++ b/src/pitch/pitchschmitt.c @@ -84,9 +84,9 @@ aubio_schmittS16LE (aubio_pitchschmitt_t * p, uint_t nframes, t1 = (sint_t) (A1 * trigfact + 0.5); t2 = -(sint_t) (A2 * trigfact + 0.5); startpoint = 0; - for (j = 1; schmittBuffer[j] <= t1 && j < blockSize; j++); - for (; !(schmittBuffer[j] >= t2 && - schmittBuffer[j + 1] < t2) && j < blockSize; j++); + for (j = 1; j < blockSize && schmittBuffer[j] <= t1; j++); + for ( ; j < blockSize - 1 && !(schmittBuffer[j] >= t2 && + schmittBuffer[j + 1] < t2); j++); startpoint = j; schmittTriggered = 0; endpoint = startpoint + 1; -- 2.26.2