shithub: aubio

Download patch

ref: 5958d1ee363b72e34ef712b8408afe7f345e1ad3
parent: 21e2e6dbc416395d697a4d54aaa58f757e1c3073
author: Paul Brossier <[email protected]>
date: Sat Dec 7 08:10:52 EST 2013

src/spectral/phasevoc.c: check win_s and hop_s

--- a/src/spectral/phasevoc.c
+++ b/src/spectral/phasevoc.c
@@ -75,9 +75,14 @@
   } */
 
   if (hop_s < 1) {
-    AUBIO_ERR("Hop size is smaller than 1!\n");
-    AUBIO_ERR("Resetting hop size to half the window size.\n");
-    hop_s = win_s / 2;
+    AUBIO_ERR("got hop_size %d, but can not be < 1\n", hop_s);
+    goto beach;
+  } else if (win_s < 1) {
+    AUBIO_ERR("got buffer_size %d, but can not be < 2\n", win_s);
+    goto beach;
+  } else if (win_s < hop_s + 1) {
+    AUBIO_ERR("hop size (%d) is larger than or equal to win size (%d)\n", win_s, hop_s);
+    goto beach;
   }
 
   pv->fft      = new_aubio_fft (win_s);
@@ -95,6 +100,10 @@
   pv->win_s    = win_s;
 
   return pv;
+
+beach:
+  AUBIO_FREE (pv);
+  return NULL;
 }
 
 void del_aubio_pvoc(aubio_pvoc_t *pv) {