From 44e94f3c409560f32cacc692ee02ae88daccd666 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Fri, 6 Dec 2013 19:56:18 -0500 Subject: [PATCH] src/synth/wavetable.c: make sure samplerate is valid --- src/synth/wavetable.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/synth/wavetable.c b/src/synth/wavetable.c index 02b9d4c6..86497aee 100644 --- a/src/synth/wavetable.c +++ b/src/synth/wavetable.c @@ -43,6 +43,10 @@ struct _aubio_wavetable_t { aubio_wavetable_t *new_aubio_wavetable(uint_t samplerate, uint_t blocksize) { aubio_wavetable_t *s = AUBIO_NEW(aubio_wavetable_t); + if ((sint_t)samplerate <= 0) { + AUBIO_ERR("Can not create wavetable with samplerate %d\n", samplerate); + goto beach; + } uint_t i = 0; s->samplerate = samplerate; s->blocksize = blocksize; @@ -59,6 +63,9 @@ aubio_wavetable_t *new_aubio_wavetable(uint_t samplerate, uint_t blocksize) s->freq = new_aubio_parameter( 0., s->samplerate / 2., 10 ); s->amp = new_aubio_parameter( 0., 1., 100 ); return s; +beach: + AUBIO_FREE(s); + return NULL; } static smpl_t interp_2(fvec_t *input, smpl_t pos) { -- 2.11.0