[vlc-commits] flac: fix leaks on error

Rémi Denis-Courmont git at videolan.org
Tue Nov 1 15:09:59 CET 2016


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Nov  1 16:09:14 2016 +0200| [165f0b11ddbfbd24ac79cce1c8b3f4e6c0905e9b] | committer: Rémi Denis-Courmont

flac: fix leaks on error

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

 modules/demux/flac.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/modules/demux/flac.c b/modules/demux/flac.c
index a386c4f..4d9b2b2 100644
--- a/modules/demux/flac.c
+++ b/modules/demux/flac.c
@@ -136,6 +136,7 @@ static int Open( vlc_object_t * p_this )
     p_demux->pf_control = Control;
     p_demux->p_sys      = p_sys;
     p_sys->b_start = true;
+    p_sys->p_packetizer = NULL;
     p_sys->p_meta = NULL;
     p_sys->i_length = 0;
     p_sys->i_pts = 0;
@@ -148,10 +149,7 @@ static int Open( vlc_object_t * p_this )
 
     /* We need to read and store the STREAMINFO metadata */
     if( ReadMeta( p_demux, &p_streaminfo, &i_streaminfo ) )
-    {
-        free( p_sys );
-        return VLC_EGENERIC;
-    }
+        goto error;
 
     /* Load the FLAC packetizer */
     /* Store STREAMINFO for the decoder and packetizer */
@@ -161,10 +159,7 @@ static int Open( vlc_object_t * p_this )
 
     p_sys->p_packetizer = demux_PacketizerNew( p_demux, &fmt, "flac" );
     if( !p_sys->p_packetizer )
-    {
-        free( p_sys );
-        return VLC_EGENERIC;
-    }
+        goto error;
 
     if( p_sys->i_cover_idx < p_sys->i_attachments )
     {
@@ -176,6 +171,9 @@ static int Open( vlc_object_t * p_this )
         vlc_meta_Set( p_sys->p_meta, vlc_meta_ArtworkURL, psz_url );
     }
     return VLC_SUCCESS;
+error:
+    Close( p_this );
+    return VLC_EGENERIC;
 }
 
 /*****************************************************************************
@@ -199,7 +197,8 @@ static void Close( vlc_object_t * p_this )
     TAB_CLEAN( p_sys->i_title_seekpoints, p_sys->pp_title_seekpoints );
 
     /* Delete the decoder */
-    demux_PacketizerDestroy( p_sys->p_packetizer );
+    if( p_sys->p_packetizer )
+        demux_PacketizerDestroy( p_sys->p_packetizer );
 
     if( p_sys->p_meta )
         vlc_meta_Delete( p_sys->p_meta );



More information about the vlc-commits mailing list