shithub: aubio

Download patch

ref: b5a0479816f1c7a51ff60b58a0499d7a34f48dd8
parent: 88d3d310cdd36c65b618a1bdc84416c2b72a0ca2
author: Paul Brossier <piem@piem.org>
date: Sat Nov 24 13:21:54 EST 2018

[tempo] make sure all objects have been created, safer del_ method

--- a/src/tempo/tempo.c
+++ b/src/tempo/tempo.c
@@ -216,12 +216,17 @@
     o2 = new_aubio_specdesc(type_onset2,buffer_size);
     onset2 = new_fvec(1);
   }*/
+  if (!o->dfframe || !o->fftgrain || !o->out || !o->pv ||
+      !o->pp || !o->od || !o->of || !o->bt || !o->onset) {
+    AUBIO_ERR("tempo: failed creating tempo object\n");
+    goto beach;
+  }
   o->last_tatum = 0;
   o->tatum_signature = 4;
   return o;
 
 beach:
-  AUBIO_FREE(o);
+  del_aubio_tempo(o);
   return NULL;
 }
 
@@ -278,15 +283,23 @@
 
 void del_aubio_tempo (aubio_tempo_t *o)
 {
-  del_aubio_specdesc(o->od);
-  del_aubio_beattracking(o->bt);
-  del_aubio_peakpicker(o->pp);
-  del_aubio_pvoc(o->pv);
-  del_fvec(o->out);
-  del_fvec(o->of);
-  del_cvec(o->fftgrain);
-  del_fvec(o->dfframe);
-  del_fvec(o->onset);
+  if (o->od)
+    del_aubio_specdesc(o->od);
+  if (o->bt)
+    del_aubio_beattracking(o->bt);
+  if (o->pp)
+    del_aubio_peakpicker(o->pp);
+  if (o->pv)
+    del_aubio_pvoc(o->pv);
+  if (o->out)
+    del_fvec(o->out);
+  if (o->of)
+    del_fvec(o->of);
+  if (o->fftgrain)
+    del_cvec(o->fftgrain);
+  if (o->dfframe)
+    del_fvec(o->dfframe);
+  if (o->onset)
+    del_fvec(o->onset);
   AUBIO_FREE(o);
-  return;
 }