]> git.sesse.net Git - vlc/commitdiff
playlist: Proper locking when editing playlist variable in loadsave.c. Also correctly...
authorPierre d'Herbemont <pdherbemont@videolan.org>
Mon, 31 Mar 2008 23:25:54 +0000 (01:25 +0200)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Mon, 31 Mar 2008 23:28:23 +0000 (01:28 +0200)
This fixes partly make check and input items leaks.

src/playlist/loadsave.c

index 55b2a2787784db373125f66be03e870e1a7f9c01..28b163e096632c782b304400de80f6e8988ea531 100644 (file)
@@ -148,19 +148,31 @@ int playlist_MLLoad( playlist_t *p_playlist )
     if( p_input == NULL )
         goto error;
 
+    PL_LOCK;
+    if( p_playlist->p_ml_onelevel->p_input )
+        vlc_gc_decref( p_playlist->p_ml_onelevel->p_input );
+    if( p_playlist->p_ml_category->p_input )
+        vlc_gc_decref( p_playlist->p_ml_category->p_input );
+
     p_playlist->p_ml_onelevel->p_input =
     p_playlist->p_ml_category->p_input = p_input;
-
     vlc_gc_incref( p_input );
+    PL_UNLOCK;
 
     vlc_event_attach( &p_input->event_manager, vlc_InputItemSubItemAdded,
                         input_item_subitem_added, p_playlist );
 
+    PL_LOCK;
     p_playlist->b_doing_ml = VLC_TRUE;
+    PL_UNLOCK;
+
     stats_TimerStart( p_playlist, "ML Load", STATS_TIMER_ML_LOAD );
     input_Read( p_playlist, p_input, VLC_TRUE );
     stats_TimerStop( p_playlist,STATS_TIMER_ML_LOAD );
+
+    PL_LOCK;
     p_playlist->b_doing_ml = VLC_FALSE;
+    PL_UNLOCK;
 
     vlc_event_detach( &p_input->event_manager, vlc_InputItemSubItemAdded,
                         input_item_subitem_added, p_playlist );