From 2abe563da12759fb6a44fa4b8b52a60f5abd3449 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Sat, 20 Sep 2014 10:23:16 -0300 Subject: [PATCH] src/pitch/pitch.c: check parameters --- src/pitch/pitch.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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 -- 2.11.0