From: Paul Brossier Date: Sat, 7 Dec 2013 00:56:18 +0000 (-0500) Subject: src/synth/wavetable.c: make sure samplerate is valid X-Git-Tag: 0.4.0-beta1~49 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=44e94f3c409560f32cacc692ee02ae88daccd666;p=aubio.git src/synth/wavetable.c: make sure samplerate is valid --- 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) {