shithub: aubio

Download patch

ref: 8fe9c106e1874e663091dd28e88dd2082db56217
parent: 1594d49e7a4c7faf2ff0cca98a04328970f1f1c3
author: Paul Brossier <piem@piem.org>
date: Wed Oct 7 22:02:11 EDT 2009

src/spectral/filterbank.c: make sure we don't read outside of boundaries

--- a/src/spectral/filterbank.c
+++ b/src/spectral/filterbank.c
@@ -62,6 +62,7 @@
   /* 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 @@
     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];
       }
     }