ref: bcc53876548334b4c5f1ebd47a5bd5f151974e8b
parent: 381a44e23279f4043c8b383708df178c588edb4b
parent: eda95c9c22b4f0b466ae94c4708765eaae6e709e
author: Paul Brossier <piem@piem.org>
date: Mon Nov 26 06:34:01 EST 2018
Merge branch 'fix/crash_filterbank' (thanks to @niugx)
--- 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
--- a/tests/src/spectral/test-filterbank.c
+++ b/tests/src/spectral/test-filterbank.c
@@ -8,6 +8,9 @@
cvec_t *in_spec = new_cvec (win_s); // input vector of samples
fvec_t *out_filters = new_fvec (n_filters); // per-band outputs
+ if (new_aubio_filterbank(0, win_s)) return 1;
+ if (new_aubio_filterbank(n_filters, 0)) return 1;
+
// create filterbank object
aubio_filterbank_t *o = new_aubio_filterbank (n_filters, win_s);