[vlc-devel] commit: libvlc_media_list_player_release: do not leak memory ( Jean-Paul Saman )

git version control git at videolan.org
Tue May 26 01:21:01 CEST 2009


vlc | branch: master | Jean-Paul Saman <jpsaman at videolan.org> | Sat May  9 21:41:16 2009 +0200| [a81a3d31f0d8f8a6d608b56dbfd7a8ce2bd884c5] | committer: Jean-Paul Saman 

libvlc_media_list_player_release: do not leak memory
(cherry picked from commit 516955892b0e912a3a100c992abee12e5b2adf24)

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

 src/control/media_list_player.c |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/src/control/media_list_player.c b/src/control/media_list_player.c
index 2981907..6df015f 100644
--- a/src/control/media_list_player.c
+++ b/src/control/media_list_player.c
@@ -295,7 +295,31 @@ libvlc_media_list_player_new( libvlc_instance_t * p_instance,
  **************************************************************************/
 void libvlc_media_list_player_release( libvlc_media_list_player_t * p_mlp )
 {
-    free(p_mlp);
+    if( !p_mlp )
+        return;
+
+    vlc_mutex_lock( &p_mlp->object_lock );
+
+    p_mlp->i_refcount--;
+    if( p_mlp->i_refcount > 0 )
+    {
+        vlc_mutex_unlock( &p_mlp->object_lock );
+        return;
+    }
+    vlc_mutex_unlock( &p_mlp->object_lock );
+    vlc_mutex_destroy( &p_mlp->object_lock );
+
+    libvlc_event_manager_release( p_mlp->p_event_manager );
+    libvlc_media_player_release( p_mlp->p_mi );
+
+    if( p_mlp->p_mlist )
+    {
+        uninstall_playlist_observer( p_mlp );
+        libvlc_media_list_release( p_mlp->p_mlist );
+    }
+
+    free( p_mlp->current_playing_item_path );
+    free( p_mlp );
 }
 
 /**************************************************************************




More information about the vlc-devel mailing list