From 13302b75fdd89b5d7398381ff1bb62a9cd3599f7 Mon Sep 17 00:00:00 2001 From: Jamie Bullock Date: Tue, 11 Nov 2008 11:55:55 +0000 Subject: - Committed patch by Chris Cannam to avoid reading past the end of an array in peak detection routine in xtract_peak_spectrum() --- src/vector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vector.c b/src/vector.c index b891111..83e44ce 100644 --- a/src/vector.c +++ b/src/vector.c @@ -435,7 +435,7 @@ int xtract_peak_spectrum(const float *data, const int N, const void *argv, float for(n = 1; n < N; n++){ if(input[n] >= threshold){ - if(input[n] > input[n - 1] && input[n] > input[n + 1]){ + if(input[n] > input[n - 1] && n + 1 < N && input[n] > input[n + 1]){ result[N + n] = q * (n + (p = .5 * ((y = input[n-1]) - (y3 = input[n+1])) / (input[n - 1] - 2 * (y2 = input[n]) + input[n + 1]))); -- cgit v1.2.3