src/io/sink_sndfile.c: avoid a small memory leak when new_sink_sndfile fails
authorPaul Brossier <piem@piem.org>
Fri, 6 Dec 2013 02:24:57 +0000 (21:24 -0500)
committerPaul Brossier <piem@piem.org>
Fri, 6 Dec 2013 02:24:57 +0000 (21:24 -0500)
src/io/sink_sndfile.c

index 801b929..7d2aaea 100644 (file)
@@ -70,6 +70,7 @@ aubio_sink_sndfile_t * new_aubio_sink_sndfile(char_t * path, uint_t samplerate)
   if (s->handle == NULL) {
     /* show libsndfile err msg */
     AUBIO_ERR("Failed opening %s. %s\n", s->path, sf_strerror (NULL));
+    AUBIO_FREE(s);
     return NULL;
   }    
 
@@ -78,6 +79,7 @@ aubio_sink_sndfile_t * new_aubio_sink_sndfile(char_t * path, uint_t samplerate)
   if (s->scratch_size >= MAX_SIZE * MAX_CHANNELS) {
     AUBIO_ERR("%d x %d exceeds maximum aubio_sink_sndfile buffer size %d\n",
         s->max_size, s->channels, MAX_CHANNELS * MAX_CHANNELS);
+    AUBIO_FREE(s);
     return NULL;
   }
   s->scratch_data = AUBIO_ARRAY(float,s->scratch_size);