filterbank.c: make sure we never write out of input/output vectors in aubio_filterbank_do
authorPaul Brossier <piem@piem.org>
Sat, 8 Sep 2007 14:12:31 +0000 (16:12 +0200)
committerPaul Brossier <piem@piem.org>
Sat, 8 Sep 2007 14:12:31 +0000 (16:12 +0200)
src/filterbank.c

index 32906151ddb7ba4c945f1c570517b41186841da9..212cf48b54b724c7c0024a530b8c490f037e85fd 100644 (file)
@@ -169,9 +169,10 @@ void del_aubio_filterbank(aubio_filterbank_t * fb){
 
 void aubio_filterbank_do(aubio_filterbank_t * f, cvec_t * in, fvec_t *out) {
   uint_t n, filter_cnt;
-  for(filter_cnt = 0; filter_cnt < f->n_filters; filter_cnt++){
+  for(filter_cnt = 0; (filter_cnt < f->n_filters)
+    && (filter_cnt < out->length); filter_cnt++){
       out->data[0][filter_cnt] = 0.f;
-      for(n = 0; n < f->win_s; n++){
+      for(n = 0; n < in->length; n++){
           out->data[0][filter_cnt] += in->norm[0][n] 
             * f->filters[filter_cnt]->data[0][n];
       }