From: Paul Brossier Date: Tue, 10 Jul 2012 22:28:39 +0000 (-0700) Subject: src/pitch/pitchschmitt.c: avoid out of bound reads X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e7e11bfb5b9dde59d259eca1438a807277655a0c;p=aubio.git src/pitch/pitchschmitt.c: avoid out of bound reads --- 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;