shithub: aubio

Download patch

ref: 44e94f3c409560f32cacc692ee02ae88daccd666
parent: 1b25a7084aa00576cc71583cacc9b2ba9cf1cf3f
author: Paul Brossier <[email protected]>
date: Fri Dec 6 14:56:18 EST 2013

src/synth/wavetable.c: make sure samplerate is valid

--- a/src/synth/wavetable.c
+++ b/src/synth/wavetable.c
@@ -43,6 +43,10 @@
 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 @@
   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) {