From a984461f81c2549a1df0d6c0160cfd5262ee2713 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Thu, 20 Aug 2015 20:26:59 +0200 Subject: [PATCH] src/spectral/fft.c: make sure winsize > 1 --- src/spectral/fft.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/spectral/fft.c b/src/spectral/fft.c index 5be398f5..7b66cad7 100644 --- a/src/spectral/fft.c +++ b/src/spectral/fft.c @@ -119,6 +119,10 @@ struct _aubio_fft_t { aubio_fft_t * new_aubio_fft (uint_t winsize) { aubio_fft_t * s = AUBIO_NEW(aubio_fft_t); + if ((sint_t)winsize < 1) { + AUBIO_ERR("fft: got winsize %d, but can not be < 1\n", winsize); + goto beach; + } #ifdef HAVE_FFTW3 uint_t i; s->winsize = winsize; @@ -170,7 +174,7 @@ aubio_fft_t * new_aubio_fft (uint_t winsize) { if (aubio_is_power_of_two(winsize) != 1) { AUBIO_ERR("fft: can only create with sizes power of two," " requested %d\n", winsize); - return NULL; + goto beach; } s->winsize = winsize; s->fft_size = winsize / 2 + 1; @@ -183,6 +187,9 @@ aubio_fft_t * new_aubio_fft (uint_t winsize) { #endif /* HAVE_ACCELERATE */ #endif /* HAVE_FFTW3 */ return s; +beach: + AUBIO_FREE(s); + return NULL; } void del_aubio_fft(aubio_fft_t * s) { -- 2.11.0