changeset 2143:4610f14103e4

fixed some memory leaks and dangling file descriptor pointers in the aac/mp4 plugin
author Ben Tucker <ben.tucker@gmail.com>
date Sun, 28 Oct 2007 16:31:12 -0700
parents 76a19617d685
children 39398ff5e162
files src/aac/libmp4.c
diffstat 1 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/aac/libmp4.c	Sun Oct 28 14:28:13 2007 -0500
+++ b/src/aac/libmp4.c	Sun Oct 28 16:31:12 2007 -0700
@@ -240,8 +240,10 @@
           !strcasecmp(extension, ".aac")    // old MPEG2/4-AAC extension
        ))
           return 1;
-       else
-          return 0;
+       else {
+            aud_vfs_fclose(file);
+            return 0;
+        }
       }
       if (!memcmp(&magic[4], "ftyp", 4)) {
            aud_vfs_fclose(file);
@@ -355,20 +357,30 @@
         guint bufferSize = 0;
         faacDecHandle decoder;
 
-        if (mp4track == -1)
+        if (mp4track == -1) {
+            // clean up
+            g_free(mp4cb);
+            aud_vfs_fclose(mp4fh);
             return NULL;
+        }
 
         decoder = faacDecOpen();
         mp4ff_get_decoder_config(mp4file, mp4track, &buffer, &bufferSize);
 
         if ( !buffer ) {
             faacDecClose(decoder);
+            // clean up
+            g_free(mp4cb);
+            aud_vfs_fclose(mp4fh);
             return FALSE;
         }
         if ( faacDecInit2(decoder, buffer, bufferSize,
                   &samplerate, &channels) < 0 ) {
             faacDecClose(decoder);
 
+            // clean up
+            g_free(mp4cb);
+            aud_vfs_fclose(mp4fh);
             return FALSE;
         }