From: Paul Brossier Date: Sat, 20 Sep 2014 13:23:16 +0000 (-0300) Subject: src/pitch/pitch.c: check parameters X-Git-Tag: 0.4.2~61 X-Git-Url: https://git.aubio.org/?p=aubio.git;a=commitdiff_plain;h=2abe563da12759fb6a44fa4b8b52a60f5abd3449 src/pitch/pitch.c: check parameters --- diff --git a/src/pitch/pitch.c b/src/pitch/pitch.c index e5b44580..b414b567 100644 --- a/src/pitch/pitch.c +++ b/src/pitch/pitch.c @@ -129,6 +129,22 @@ new_aubio_pitch (char_t * pitch_mode, pitch_mode); pitch_type = aubio_pitcht_default; } + + // check parameters are valid + if ((sint_t)hopsize < 1) { + AUBIO_ERR("onset: got hopsize %d, but can not be < 1\n", hopsize); + goto beach; + } else if ((sint_t)bufsize < 1) { + AUBIO_ERR("onset: got buffer_size %d, but can not be < 1\n", bufsize); + goto beach; + } else if (bufsize < hopsize) { + AUBIO_ERR("onset: hop size (%d) is larger than win size (%d)\n", bufsize, hopsize); + goto beach; + } else if ((sint_t)samplerate < 1) { + AUBIO_ERR("onset: samplerate (%d) can not be < 1\n", samplerate); + goto beach; + } + p->samplerate = samplerate; p->type = pitch_type; aubio_pitch_set_unit (p, "default"); @@ -178,6 +194,10 @@ new_aubio_pitch (char_t * pitch_mode, break; } return p; + +beach: + AUBIO_FREE(p); + return NULL; } void