From 99aa35348d127d5d3582ad69d8f730b298766957 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Mon, 2 May 2016 12:05:39 +0200 Subject: [PATCH] python/ext/py-phasevoc.c: add input size checks --- python/ext/py-phasevoc.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/python/ext/py-phasevoc.c b/python/ext/py-phasevoc.c index 0c9e2c2b..71bb5d58 100644 --- a/python/ext/py-phasevoc.c +++ b/python/ext/py-phasevoc.c @@ -102,6 +102,13 @@ Py_pvoc_do(Py_pvoc * self, PyObject * args) return NULL; } + if (self->vecin.length != self->hop_s) { + PyErr_Format(PyExc_ValueError, + "input fvec has length %d, but pvoc expects length %d", + self->vecin.length, self->hop_s); + return NULL; + } + Py_INCREF(self->output); if (!PyAubio_PyCvecToCCvec (self->output, &(self->c_output))) { return NULL; @@ -131,6 +138,13 @@ Py_pvoc_rdo(Py_pvoc * self, PyObject * args) return NULL; } + if (self->cvecin.length != self->win_s / 2 + 1) { + PyErr_Format(PyExc_ValueError, + "input cvec has length %d, but pvoc expects length %d", + self->cvecin.length, self->win_s / 2 + 1); + return NULL; + } + Py_INCREF(self->routput); if (!PyAubio_ArrayToCFvec(self->routput, &(self->c_routput)) ) { return NULL; -- 2.11.0