[xiph-commits] r18382 - trunk/vorbis-tools/oggenc

tterribe at svn.xiph.org tterribe at svn.xiph.org
Tue Jun 12 18:59:26 PDT 2012


Author: tterribe
Date: 2012-06-12 18:59:26 -0700 (Tue, 12 Jun 2012)
New Revision: 18382

Modified:
   trunk/vorbis-tools/oggenc/flac.c
Log:
Fix a memory leak in the FLAC decoder.

resize_buffer() would only free the channel buffers when the
 channel count changed, not when the size of the buffer changed,
 even though it allocated new buffers in both cases.


Modified: trunk/vorbis-tools/oggenc/flac.c
===================================================================
--- trunk/vorbis-tools/oggenc/flac.c	2012-06-13 00:44:53 UTC (rev 18381)
+++ trunk/vorbis-tools/oggenc/flac.c	2012-06-13 01:59:26 UTC (rev 18382)
@@ -341,17 +341,15 @@
         return;
     }
 
+    /* Deallocate all of the sample vectors */
+    for (i = 0; i < flac->channels; i++)
+        free(flac->buf[i]);
 
     /* Not the most efficient approach, but it is easy to follow */
     if(newchannels != flac->channels)
     {
-        /* Deallocate all of the sample vectors */
-        for (i = 0; i < flac->channels; i++)
-            free(flac->buf[i]);
-
         flac->buf = realloc(flac->buf, sizeof(float*) * newchannels);
         flac->channels = newchannels;
-
     }
 
     for (i = 0; i < newchannels; i++)



More information about the commits mailing list