Changeset de0a492


Ignore:
Timestamp:
May 3, 2016, 4:19:28 AM (3 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
fcef3fd
Parents:
7aed123
Message:

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

Location:
python
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/ext/py-filterbank.c

    r7aed123 rde0a492  
    9090
    9191  if (!PyAubio_PyCvecToCCvec(input, &(self->vec) )) {
     92    return NULL;
     93  }
     94
     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);
    9299    return NULL;
    93100  }
  • python/tests/test_filterbank.py

    r7aed123 rde0a492  
    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
    6474if __name__ == '__main__':
    6575    from nose2 import main
Note: See TracChangeset for help on using the changeset viewer.