ref: de0a49250d04d9322d46172196df711494ac756d
parent: 7aed123d4be229ea351686c1b07abb2545fbc58a
author: Paul Brossier <piem@piem.org>
date: Tue May 3 00:19:28 EDT 2016
python/ext/py-filterbank.c: check input size
--- a/python/ext/py-filterbank.c
+++ b/python/ext/py-filterbank.c
@@ -92,6 +92,13 @@
return NULL;
}
+ if (self->vec.length != self->win_s / 2 + 1) {
+ PyErr_Format(PyExc_ValueError,
+ "input cvec has length %d, but fft expects length %d",
+ self->vec.length, self->win_s / 2 + 1);
+ return NULL;
+ }
+
Py_INCREF(self->out);
if (!PyAubio_ArrayToCFvec(self->out, &(self->c_out))) {
return NULL;
--- a/python/tests/test_filterbank.py
+++ b/python/tests/test_filterbank.py
@@ -61,6 +61,16 @@
f.set_mel_coeffs_slaney(16000)
assert_almost_equal ( expected, f.get_coeffs() )
+ def test_filterbank_long_cvec(self):
+ f = filterbank(40, 512)
+ with self.assertRaises(ValueError):
+ f(cvec(1024))
+
+ def test_filterbank_short_cvec(self):
+ f = filterbank(40, 512)
+ with self.assertRaises(ValueError):
+ f(cvec(256))
+
if __name__ == '__main__':
from nose2 import main
main()