Handle NULL value in "input-current" callback
authorRémi Denis-Courmont <remi@remlab.net>
Sat, 16 Aug 2014 12:28:25 +0000 (15:28 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Sat, 16 Aug 2014 12:48:57 +0000 (15:48 +0300)
modules/control/gestures.c
modules/control/netsync.c
modules/gui/skins2/src/vlcproc.cpp

index d526971..a820b55 100644 (file)
@@ -508,8 +508,12 @@ static int PlaylistEvent( vlc_object_t *p_this, char const *psz_var,
 
     (void) p_this; (void) psz_var; (void) oldval;
 
 
     (void) p_this; (void) psz_var; (void) oldval;
 
-    var_AddCallback( p_input, "intf-event", InputEvent, p_intf );
     assert( p_sys->p_input == NULL );
     assert( p_sys->p_input == NULL );
-    p_sys->p_input = vlc_object_hold( 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;
 }
     return VLC_SUCCESS;
 }
index 88bc429..2ced26b 100644 (file)
@@ -289,17 +289,21 @@ static int PlaylistEvent(vlc_object_t *object, char const *cmd,
     VLC_UNUSED(cmd); VLC_UNUSED(oldval); VLC_UNUSED(object);
     intf_thread_t  *intf = data;
     intf_sys_t     *sys = intf->p_sys;
     VLC_UNUSED(cmd); VLC_UNUSED(oldval); VLC_UNUSED(object);
     intf_thread_t  *intf = data;
     intf_sys_t     *sys = intf->p_sys;
-
     input_thread_t *input = newval.p_address;
     input_thread_t *input = newval.p_address;
+
     assert(sys->input == NULL);
     assert(sys->input == NULL);
-    sys->input = vlc_object_hold(input);
-    if (vlc_clone(&sys->thread, sys->is_master ? Master : Slave, intf,
-                  VLC_THREAD_PRIORITY_INPUT)) {
-        vlc_object_release(input);
-        sys->input = NULL;
-        return VLC_SUCCESS;
+
+    if (input != NULL)
+    {
+        sys->input = vlc_object_hold(input);
+        if (vlc_clone(&sys->thread, sys->is_master ? Master : Slave, intf,
+                      VLC_THREAD_PRIORITY_INPUT)) {
+            vlc_object_release(input);
+            sys->input = NULL;
+            return VLC_SUCCESS;
+        }
+        var_AddCallback(input, "intf-event", InputEvent, intf);
     }
     }
-    var_AddCallback(input, "intf-event", InputEvent, intf);
     return VLC_SUCCESS;
 }
 
     return VLC_SUCCESS;
 }
 
index dcf3b30..7cf4882 100644 (file)
@@ -227,11 +227,13 @@ int VlcProc::onInputNew( vlc_object_t *pObj, const char *pVariable,
     VlcProc *pThis = (VlcProc*)pParam;
     input_thread_t *pInput = static_cast<input_thread_t*>(newval.p_address);
 
     VlcProc *pThis = (VlcProc*)pParam;
     input_thread_t *pInput = static_cast<input_thread_t*>(newval.p_address);
 
-    var_AddCallback( pInput, "intf-event", onGenericCallback2, pThis );
-    var_AddCallback( pInput, "bit-rate", onGenericCallback, pThis );
-    var_AddCallback( pInput, "sample-rate", onGenericCallback, pThis );
-    var_AddCallback( pInput, "can-record", onGenericCallback, pThis );
-
+    if( pInput != NULL )
+    {
+        var_AddCallback( pInput, "intf-event", onGenericCallback2, pThis );
+        var_AddCallback( pInput, "bit-rate", onGenericCallback, pThis );
+        var_AddCallback( pInput, "sample-rate", onGenericCallback, pThis );
+        var_AddCallback( pInput, "can-record", onGenericCallback, pThis );
+    }
     return VLC_SUCCESS;
 }
 
     return VLC_SUCCESS;
 }