[vlc-commits] Fix many memory leaks (and potential ones)

Rémi Duraffort git at videolan.org
Fri Jul 26 19:34:11 CEST 2013


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Tue Jul 23 21:55:22 2013 +0200| [e66123d2a869284ac4c5e3f95847b969ec6d85ff] | committer: Rémi Duraffort

Fix many memory leaks (and potential ones)

In case of a wrongly formated file, the strings where never dealocated. Same if
some strings where empty.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e66123d2a869284ac4c5e3f95847b969ec6d85ff
---

 modules/demux/playlist/zpl.c |   20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/modules/demux/playlist/zpl.c b/modules/demux/playlist/zpl.c
index fb25e01..0d15cce 100644
--- a/modules/demux/playlist/zpl.c
+++ b/modules/demux/playlist/zpl.c
@@ -175,8 +175,8 @@ static int Demux( demux_t *p_demux )
     if( !EMPTY_STR(variable) )                          \
     {                                                   \
         input_item_Set##type( p_input, variable );      \
-        FREENULL( variable );                           \
-    }
+    }                                                   \
+    FREENULL( variable );
             /* set the meta */
             SET( psz_genre, Genre );
             SET( psz_tracknum, TrackNum );
@@ -204,6 +204,22 @@ static int Demux( demux_t *p_demux )
     input_item_node_PostAndDelete( p_subitems );
 
     vlc_gc_decref(p_current_input);
+
+    // Free everything if the file is wrongly formated
+    free( psz_title );
+    free( psz_genre );
+    free( psz_tracknum );
+    free( psz_language );
+    free( psz_artist );
+    free( psz_album );
+    free( psz_date );
+    free( psz_publisher );
+    free( psz_encodedby );
+    free( psz_description );
+    free( psz_url );
+    free( psz_copyright );
+    free( psz_mrl );
+
     var_Destroy( p_demux, "zpl-extvlcopt" );
     return 0; /* Needed for correct operation of go back */
 }



More information about the vlc-commits mailing list