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

Rémi Duraffort git at videolan.org
Fri Aug 9 10:37:22 CEST 2013


vlc/vlc-2.1 | branch: master | Rémi Duraffort <ivoire at videolan.org> | Tue Jul 23 21:55:22 2013 +0200| [2c3099a97e30cb0354a436866f8a23dad28151fe] | committer: Jean-Baptiste Kempf

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.

(cherry picked from commit e66123d2a869284ac4c5e3f95847b969ec6d85ff)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 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 0628113..f909c47 100644
--- a/modules/demux/playlist/zpl.c
+++ b/modules/demux/playlist/zpl.c
@@ -179,8 +179,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 );
@@ -208,6 +208,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