shithub: aubio

Download patch

ref: eda95c9c22b4f0b466ae94c4708765eaae6e709e
parent: 1029ac707264007902cff59ba44e1a7e226ab909
author: Paul Brossier <piem@piem.org>
date: Sat Nov 24 11:29:45 EST 2018

[filterbank] validate input parameters

--- a/src/spectral/filterbank.c
+++ b/src/spectral/filterbank.c
@@ -42,6 +42,15 @@
 {
   /* allocate space for filterbank object */
   aubio_filterbank_t *fb = AUBIO_NEW (aubio_filterbank_t);
+
+  if ((sint_t)n_filters <= 0) {
+    AUBIO_ERR("filterbank: n_filters should be > 0, got %d\n", n_filters);
+    goto fail;
+  }
+  if ((sint_t)win_s <= 0) {
+    AUBIO_ERR("filterbank: win_s should be > 0, got %d\n", win_s);
+    goto fail;
+  }
   fb->win_s = win_s;
   fb->n_filters = n_filters;
 
@@ -53,6 +62,9 @@
   fb->power = 1;
 
   return fb;
+fail:
+  AUBIO_FREE (fb);
+  return NULL;
 }
 
 void