From 8fe9c106e1874e663091dd28e88dd2082db56217 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Thu, 8 Oct 2009 02:02:11 +0200 Subject: [PATCH] src/spectral/filterbank.c: make sure we don't read outside of boundaries --- src/spectral/filterbank.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/spectral/filterbank.c b/src/spectral/filterbank.c index ac3d7e35..4a077c99 100644 --- a/src/spectral/filterbank.c +++ b/src/spectral/filterbank.c @@ -62,6 +62,7 @@ aubio_filterbank_do (aubio_filterbank_t * f, cvec_t * in, fvec_t * out) /* apply filter to all input channel, provided out has enough channels */ uint_t max_channels = MIN (in->channels, out->channels); uint_t max_filters = MIN (f->n_filters, out->length); + uint_t max_length = MIN (in->length, f->filters->length); /* reset all values in output vector */ fvec_zeros (out); @@ -73,7 +74,7 @@ aubio_filterbank_do (aubio_filterbank_t * f, cvec_t * in, fvec_t * out) for (fn = 0; fn < max_filters; fn++) { /* for each sample */ - for (j = 0; j < in->length; j++) { + for (j = 0; j < max_length; j++) { out->data[i][fn] += in->norm[i][j] * f->filters->data[fn][j]; } } -- 2.26.2