]> git.sesse.net Git - vlc/commitdiff
* ALL: fixed a bunch of memory leaks.
authorGildas Bazin <gbazin@videolan.org>
Wed, 23 Oct 2002 21:54:33 +0000 (21:54 +0000)
committerGildas Bazin <gbazin@videolan.org>
Wed, 23 Oct 2002 21:54:33 +0000 (21:54 +0000)
modules/access/dvdplay/tools.c
modules/access/dvdread/input.c
modules/demux/aac/demux.c
modules/demux/mpeg/audio.c

index 709fe72b283bf1fe197020f21a216baab1d23713..e00d7038b11163d1f3f85e4c0cee5a4967c469a5 100644 (file)
@@ -2,7 +2,7 @@
  * tools.c: tools for dvd plugin.
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: tools.c,v 1.1 2002/08/04 17:23:42 sam Exp $
+ * $Id: tools.c,v 1.2 2002/10/23 21:54:33 gbazin Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
@@ -97,12 +97,14 @@ char * dvdplay_ParseCL( input_thread_t * p_input,
             return NULL;
         }
         psz_source = config_GetPsz( p_input, "dvd" );
+        if( !psz_source ) return NULL;
     }
 
     if( stat( psz_source, &stat_info ) == -1 )
     {
         msg_Err( p_input, "cannot stat() source `%s' (%s)",
                      psz_source, strerror(errno));
+        free( psz_source );
         return NULL;
     }
     if( !S_ISBLK(stat_info.st_mode) &&
@@ -111,6 +113,7 @@ char * dvdplay_ParseCL( input_thread_t * p_input,
     {
         msg_Dbg( p_input, "plugin discarded"
                          " (not a valid source)" );
+        free( psz_source );
         return NULL;
     }
     
index 9c956c91d504184e2bb30c74329e169bdf3a5978..4859aaa270929013bdadc55aaf32dfc2b9169a69 100644 (file)
@@ -6,7 +6,7 @@
  * It depends on: libdvdread for ifo files and block reading.
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: input.c,v 1.4 2002/08/30 22:22:24 massiot Exp $
+ * $Id: input.c,v 1.5 2002/10/23 21:54:33 gbazin Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
@@ -236,7 +236,6 @@ static int DvdReadRewind( input_thread_t * p_input )
 int E_(OpenDVD) ( vlc_object_t *p_this )
 {
     input_thread_t *        p_input = (input_thread_t *)p_this;
-    char *                  psz_orig;
     char *                  psz_parser;
     char *                  psz_source;
     char *                  psz_next;
@@ -249,8 +248,8 @@ int E_(OpenDVD) ( vlc_object_t *p_this )
     int                     i_angle = 1;
     int                     i;
 
-    psz_orig = psz_parser = psz_source = strdup( p_input->psz_name );
-    if( !psz_orig )
+    psz_parser = psz_source = strdup( p_input->psz_name );
+    if( !psz_source )
     {
         return( -1 );
     }
@@ -289,18 +288,20 @@ int E_(OpenDVD) ( vlc_object_t *p_this )
 
     if( !*psz_source )
     {
+        free( psz_source );
         if( !p_input->psz_access )
         {
-            free( psz_orig );
             return -1;
         }
         psz_source = config_GetPsz( p_input, "dvd" );
+        if( !psz_source ) return -1;
     }
 
     if( stat( psz_source, &stat_info ) == -1 )
     {
         msg_Err( p_input, "cannot stat() source `%s' (%s)",
                           psz_source, strerror(errno));
+        free( psz_source );
         return( -1 );
     }
     if( !S_ISBLK(stat_info.st_mode) &&
@@ -308,6 +309,7 @@ int E_(OpenDVD) ( vlc_object_t *p_this )
         !S_ISDIR(stat_info.st_mode) )
     {
         msg_Warn( p_input, "dvdread module discarded (not a valid source)" );
+        free( psz_source );
         return -1;
     }
     
@@ -318,9 +320,7 @@ int E_(OpenDVD) ( vlc_object_t *p_this )
     p_dvdread = DVDOpen( psz_source );
 
     /* free allocated strings */
-    if( psz_source != psz_orig )
-        free( psz_source );
-    free( psz_orig );
+    free( psz_source );
 
     if( ! p_dvdread )
     {
index fc1925c90e43d33dc4b80632ac3a10e17315242f..26afb09e5558560521b9e7117ba7a89be604cb7a 100644 (file)
@@ -2,7 +2,7 @@
  * demux.c : Raw aac Stream input module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: demux.c,v 1.2 2002/08/24 21:35:31 sigmunau Exp $
+ * $Id: demux.c,v 1.3 2002/10/23 21:54:33 gbazin Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  * 
@@ -475,11 +475,13 @@ static int Activate( vlc_object_t * p_this )
     vlc_mutex_lock( &p_input->stream.stream_lock );
     if( input_InitStream( p_input, 0 ) == -1)
     {
+        vlc_mutex_unlock( &p_input->stream.stream_lock );
         msg_Err( p_input, "cannot init stream" );
         return( -1 );
     }    
     if( input_AddProgram( p_input, 0, 0) == NULL )
     {
+        vlc_mutex_unlock( &p_input->stream.stream_lock );
         msg_Err( p_input, "cannot add program" );
         return( -1 );
     }
index 8cd8c10b0da0672cc54d19b247a35acbacb79f4b..85a407096f3813f40ccfe6756dc5a2ec27974eb4 100644 (file)
@@ -2,7 +2,7 @@
  * audio.c : mpeg audio Stream input module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: audio.c,v 1.8 2002/08/24 21:35:31 sigmunau Exp $
+ * $Id: audio.c,v 1.9 2002/10/23 21:54:33 gbazin Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  * 
@@ -513,6 +513,7 @@ static int Activate( vlc_object_t * p_this )
     /* check if it could be a ps stream */
     if( !b_forced && CheckPS(  p_input ))
     {
+        free( p_input->p_demux_data );
         return( -1 );
     }
 
@@ -532,6 +533,7 @@ static int Activate( vlc_object_t * p_this )
         else
         {
             msg_Warn( p_input, "MPEGAudio module discarded (no frame found)" );
+            free( p_input->p_demux_data );
             return( -1 );
         }
     }
@@ -545,11 +547,13 @@ static int Activate( vlc_object_t * p_this )
     if( input_InitStream( p_input, 0 ) == -1)
     {
         msg_Err( p_input, "cannot init stream" );
+        free( p_input->p_demux_data );
         return( -1 );
     }    
     if( input_AddProgram( p_input, 0, 0) == NULL )
     {
         msg_Err( p_input, "cannot add program" );
+        free( p_input->p_demux_data );
         return( -1 );
     }
     p_input->stream.pp_programs[0]->b_is_ok = 0;
@@ -564,6 +568,7 @@ static int Activate( vlc_object_t * p_this )
     {
         vlc_mutex_unlock( &p_input->stream.stream_lock );
         msg_Err( p_input, "out of memory" );
+        free( p_input->p_demux_data );
         return( -1 );
     }
     p_demux->p_es->i_stream_id = 1;