From 927f6306121b4e2c408a2d763cb0c23040b65206 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Sat, 9 Feb 2013 20:13:55 -0500 Subject: [PATCH] src/temporal/resampler.c: safer new_ and del_ --- src/temporal/resampler.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/temporal/resampler.c b/src/temporal/resampler.c index 21fe5af2..8f123b62 100644 --- a/src/temporal/resampler.c +++ b/src/temporal/resampler.c @@ -42,9 +42,12 @@ new_aubio_resampler (smpl_t ratio, uint_t type) 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 @@ new_aubio_resampler (smpl_t ratio, uint_t type) 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); } -- 2.26.2