History

python/ext/py-filterbank.c: check input size

Paul Brossier committed 10 years ago

Commit de0a4921 parent 7aed1232 files · +17 −0Browse files

Showing the changes to python (2 of 2 files). Show all

Unified · Split

2 files
  1. python/ext/py-filterbank.c +7 −0
  2. python/tests/test_filterbank.py +10 −0
python/ext/py-filterbank.c+7−0
@@ -92,6 +92,13 @@ Py_filterbank_do(Py_filterbank * self, PyObject * args) · 91 unmodified lines
9292 return NULL;
9393 }
9494
95+ if (self->vec.length != self->win_s / 2 + 1) {
96+ PyErr_Format(PyExc_ValueError,
97+ "input cvec has length %d, but fft expects length %d",
98+ self->vec.length, self->win_s / 2 + 1);
99+ return NULL;
100+ }
101+
95102 Py_INCREF(self->out);
96103 if (!PyAubio_ArrayToCFvec(self->out, &(self->c_out))) {
97104 return NULL;
python/tests/test_filterbank.py+10−0
@@ -61,6 +61,16 @@ class aubio_filterbank_test_case(TestCase): · 60 unmodified lines
6161 f.set_mel_coeffs_slaney(16000)
6262 assert_almost_equal ( expected, f.get_coeffs() )
6363
64+ def test_filterbank_long_cvec(self):
65+ f = filterbank(40, 512)
66+ with self.assertRaises(ValueError):
67+ f(cvec(1024))
68+
69+ def test_filterbank_short_cvec(self):
70+ f = filterbank(40, 512)
71+ with self.assertRaises(ValueError):
72+ f(cvec(256))
73+
6474 if __name__ == '__main__':
6575 from nose2 import main
6676 main()

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t