ref: 927f6306121b4e2c408a2d763cb0c23040b65206
parent: 25c9f9ac65ef6d0c66a90795f9b1fd6835e28d2c
author: Paul Brossier <piem@piem.org>
date: Sat Feb 9 15:13:55 EST 2013
src/temporal/resampler.c: safer new_ and del_
--- a/src/temporal/resampler.c
+++ b/src/temporal/resampler.c
@@ -42,9 +42,12 @@
aubio_resampler_t *s = AUBIO_NEW (aubio_resampler_t);
int error = 0;
s->stat = src_new (type, 1, &error); /* only one channel */
+ if (error) {
+ AUBIO_ERR ("Failed creating resampler: %s\n", src_strerror (error));
+ del_aubio_resampler(s);
+ return NULL;
+ }
s->proc = AUBIO_NEW (SRC_DATA);
- if (error)
- AUBIO_ERR ("%s\n", src_strerror (error));
s->ratio = ratio;
return s;
}
@@ -52,7 +55,7 @@
void
del_aubio_resampler (aubio_resampler_t * s)
{
- src_delete (s->stat);
+ if (s->stat) src_delete (s->stat);
AUBIO_FREE (s->proc);
AUBIO_FREE (s);
}