[vlc-devel] commit: (live555) fix memory leaks in closing/error paths. ( Jean-Paul Saman )

git version control git at videolan.org
Tue Dec 9 20:48:39 CET 2008


vlc | branch: 0.8.6-bugfix | Jean-Paul Saman <jpsaman at videolan.org> | Thu Nov 27 12:12:32 2008 +0100| [46167a51a9ec33050d58a371161cbebfe54cf73f] | committer: Jean-Paul Saman 

(live555) fix memory leaks in closing/error paths.

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

 modules/demux/live555.cpp |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/modules/demux/live555.cpp b/modules/demux/live555.cpp
index e9449c9..9200545 100644
--- a/modules/demux/live555.cpp
+++ b/modules/demux/live555.cpp
@@ -233,6 +233,7 @@ static int  Open ( vlc_object_t *p_this )
     MediaSubsessionIterator *iter   = NULL;
     MediaSubsession         *sub    = NULL;
     int i_return;
+    int i;
 
     if( p_demux->s )
     {
@@ -676,7 +677,20 @@ static int  Open ( vlc_object_t *p_this )
     return VLC_SUCCESS;
 
 error:
+    for( i = 0; i < p_sys->i_track; i++ )
+    {
+        live_track_t *tk = p_sys->track[i];
+
+        if( tk->b_muxed ) stream_DemuxDelete( tk->p_out_muxed );
+        es_format_Clean( &tk->fmt );
+        free( tk->p_buffer );
+        free( tk );
+    }
+    free( p_sys->track );
+    p_sys->i_track = 0;
+
     if( p_sys->p_out_asf ) stream_DemuxDelete( p_sys->p_out_asf );
+    if( p_sys->rtsp && p_sys->ms ) p_sys->rtsp->teardownMediaSession( *p_sys->ms );
     if( p_sys->ms ) Medium::close( p_sys->ms );
     if( p_sys->rtsp ) RTSPClient::close( p_sys->rtsp );
     if( p_sys->env ) RECLAIM_ENV(p_sys->env);
@@ -687,9 +701,9 @@ error:
         vlc_object_detach( p_sys->p_timeout );
         vlc_object_destroy( p_sys->p_timeout );
     }
-    if( p_sys->scheduler ) delete p_sys->scheduler;
-    if( p_sys->p_sdp ) free( p_sys->p_sdp );
-    if( p_sys->psz_path ) free( p_sys->psz_path );
+    delete p_sys->scheduler;
+    free( p_sys->p_sdp );
+    free( p_sys->psz_path );
 
     vlc_UrlClean( &p_sys->url );
     free( p_sys );
@@ -710,11 +724,13 @@ static void Close( vlc_object_t *p_this )
         live_track_t *tk = p_sys->track[i];
 
         if( tk->b_muxed ) stream_DemuxDelete( tk->p_out_muxed );
+        es_format_Clean( &tk->fmt );
         free( tk->p_buffer );
         free( tk );
     }
 
-    if( p_sys->i_track ) free( p_sys->track );
+    free( p_sys->track );
+    p_sys->i_track = 0;
     if( p_sys->p_out_asf ) stream_DemuxDelete( p_sys->p_out_asf );
 
     if( p_sys->rtsp && p_sys->ms )
@@ -723,7 +739,7 @@ static void Close( vlc_object_t *p_this )
         p_sys->rtsp->teardownMediaSession( *p_sys->ms );
     }
 
-    Medium::close( p_sys->ms );
+    if( p_sys->ms ) Medium::close( p_sys->ms );
 
     if( p_sys->p_timeout )
     {
@@ -735,9 +751,9 @@ static void Close( vlc_object_t *p_this )
 
     if( p_sys->rtsp ) RTSPClient::close( p_sys->rtsp );
     if( p_sys->env ) RECLAIM_ENV( p_sys->env );
-    if( p_sys->scheduler ) delete p_sys->scheduler;
-    if( p_sys->p_sdp ) free( p_sys->p_sdp );
-    if( p_sys->psz_path ) free( p_sys->psz_path );
+    delete p_sys->scheduler;
+    free( p_sys->p_sdp );
+    free( p_sys->psz_path );
 
     vlc_UrlClean( &p_sys->url );
 




More information about the vlc-devel mailing list