[vlc-commits] gestures: fix callback leak and missing locking

Rémi Denis-Courmont git at videolan.org
Sat Aug 16 14:48:57 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Aug 16 15:47:50 2014 +0300| [efa6a6fe9c22dff01a9ca65f79ca62c6a3420611] | committer: Rémi Denis-Courmont

gestures: fix callback leak and missing locking

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

 modules/control/gestures.c |   24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/modules/control/gestures.c b/modules/control/gestures.c
index a820b55..e04dd2f 100644
--- a/modules/control/gestures.c
+++ b/modules/control/gestures.c
@@ -163,11 +163,8 @@ static void Close ( vlc_object_t *p_this )
     /* Destroy the callbacks (the order matters!) */
     var_DelCallback( pl_Get(p_intf), "input-current", PlaylistEvent, p_intf );
 
-    if( p_sys->p_input )
-    {
+    if( p_sys->p_input != NULL )
         var_DelCallback( p_sys->p_input, "intf-event", InputEvent, p_intf );
-        vlc_object_release( p_sys->p_input );
-    }
 
     if( p_sys->p_vout )
     {
@@ -469,11 +466,6 @@ static int InputEvent( vlc_object_t *p_this, char const *psz_var,
 
     switch( val.i_int )
     {
-      case INPUT_EVENT_DEAD:
-        vlc_object_release( p_input );
-        p_sys->p_input = NULL; /* FIXME: locking!! */
-        break;
-
       case INPUT_EVENT_VOUT:
         /* intf-event is serialized against itself and is the sole user of
          * p_sys->p_vout. So there is no need to acquire the lock currently. */
@@ -506,14 +498,18 @@ static int PlaylistEvent( vlc_object_t *p_this, char const *psz_var,
     intf_sys_t *p_sys = p_intf->p_sys;
     input_thread_t *p_input = val.p_address;
 
-    (void) p_this; (void) psz_var; (void) oldval;
+    (void) p_this; (void) psz_var;
+
+    if( p_sys->p_input != NULL )
+    {
+        assert( p_sys->p_input == oldval.p_address );
+        var_DelCallback( p_sys->p_input, "intf-event", InputEvent, p_intf );
+    }
 
-    assert( p_sys->p_input == NULL );
+    p_sys->p_input = p_input;
 
     if( p_input != NULL )
-    {
         var_AddCallback( p_input, "intf-event", InputEvent, p_intf );
-        p_sys->p_input = vlc_object_hold( p_input );
-    }
+
     return VLC_SUCCESS;
 }



More information about the vlc-commits mailing list