ref: 4cb7a0ab8d9ff08153e4c8d392d6cbd69b29eed4
parent: 0f2c1f43182106c63ed499de2c04d2b47788cf97
author: Paul Brossier <piem@piem.org>
date: Thu Jan 12 17:59:04 EST 2017
src/pitch/pitch.c: return NULL if creation failed
--- a/src/pitch/pitch.c
+++ b/src/pitch/pitch.c
@@ -155,6 +155,7 @@
case aubio_pitcht_yin:
p->buf = new_fvec (bufsize);
p->p_object = new_aubio_pitchyin (bufsize);
+ if (!p->p_object) goto beach;
p->detect_cb = aubio_pitch_do_yin;
p->conf_cb = (aubio_pitch_get_conf_t)aubio_pitchyin_get_confidence;
aubio_pitchyin_set_tolerance (p->p_object, 0.15);
@@ -162,6 +163,7 @@
case aubio_pitcht_mcomb:
p->filtered = new_fvec (hopsize);
p->pv = new_aubio_pvoc (bufsize, hopsize);
+ if (!p->pv) goto beach;
p->fftgrain = new_cvec (bufsize);
p->p_object = new_aubio_pitchmcomb (bufsize, hopsize);
p->filter = new_aubio_filter_c_weighting (samplerate);
@@ -170,6 +172,7 @@
case aubio_pitcht_fcomb:
p->buf = new_fvec (bufsize);
p->p_object = new_aubio_pitchfcomb (bufsize, hopsize);
+ if (!p->p_object) goto beach;
p->detect_cb = aubio_pitch_do_fcomb;
break;
case aubio_pitcht_schmitt:
@@ -180,6 +183,7 @@
case aubio_pitcht_yinfft:
p->buf = new_fvec (bufsize);
p->p_object = new_aubio_pitchyinfft (samplerate, bufsize);
+ if (!p->p_object) goto beach;
p->detect_cb = aubio_pitch_do_yinfft;
p->conf_cb = (aubio_pitch_get_conf_t)aubio_pitchyinfft_get_confidence;
aubio_pitchyinfft_set_tolerance (p->p_object, 0.85);
@@ -187,6 +191,7 @@
case aubio_pitcht_specacf:
p->buf = new_fvec (bufsize);
p->p_object = new_aubio_pitchspecacf (bufsize);
+ if (!p->p_object) goto beach;
p->detect_cb = aubio_pitch_do_specacf;
p->conf_cb = (aubio_pitch_get_conf_t)aubio_pitchspecacf_get_tolerance;
aubio_pitchspecacf_set_tolerance (p->p_object, 0.85);
@@ -197,6 +202,8 @@
return p;
beach:
+ if (p->filtered) del_fvec(p->filtered);
+ if (p->buf) del_fvec(p->buf);
AUBIO_FREE(p);
return NULL;
}