shithub: aubio

Download patch

ref: 7876b67aca5b6aff2cda6b721b2aba1764e0c1aa
parent: dee266fc68ee724ec5b1eb27445940dc5dedb1ad
author: Paul Brossier <piem@piem.org>
date: Fri May 13 13:22:32 EDT 2016

python/ext/py-filterbank.c: fix error message formatting, do not delete if not created

--- a/python/ext/py-filterbank.c
+++ b/python/ext/py-filterbank.c
@@ -59,10 +59,8 @@
 {
   self->o = new_aubio_filterbank (self->n_filters, self->win_s);
   if (self->o == NULL) {
-    char_t errstr[30];
-    sprintf(errstr, "error creating filterbank with n_filters=%d, win_s=%d",
-        self->n_filters, self->win_s);
-    PyErr_SetString (PyExc_RuntimeError, errstr);
+    PyErr_Format(PyExc_RuntimeError, "error creating filterbank with"
+        " n_filters=%d, win_s=%d", self->n_filters, self->win_s);
     return -1;
   }
   self->out = new_py_fvec(self->n_filters);
@@ -73,9 +71,11 @@
 static void
 Py_filterbank_del (Py_filterbank *self, PyObject *unused)
 {
-  del_aubio_filterbank(self->o);
-  Py_DECREF(self->out);
-  free(self->coeffs.data);
+  if (self->o) {
+    free(self->coeffs.data);
+    del_aubio_filterbank(self->o);
+  }
+  Py_XDECREF(self->out);
   Py_TYPE(self)->tp_free((PyObject *) self);
 }