[vlc-devel] [vlc-commits] dbus: fix vlc_array_remove sign (cid #1401376)

Rémi Denis-Courmont remi at remlab.net
Thu Feb 23 18:11:54 CET 2017


On February 23, 2017 3:46:13 PM GMT+02:00, git at videolan.org wrote:
>vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Feb 23
>14:31:23 2017 +0100| [f4b096149ed692dcd0196930b3b149eb9c2257f0] |
>committer: Thomas Guillem
>
>dbus: fix vlc_array_remove sign (cid #1401376)
>
>>
>http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f4b096149ed692dcd0196930b3b149eb9c2257f0
>---
>
> modules/control/dbus/dbus.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
>diff --git a/modules/control/dbus/dbus.c b/modules/control/dbus/dbus.c
>index 46692c5..2bd74d9 100644
>--- a/modules/control/dbus/dbus.c
>+++ b/modules/control/dbus/dbus.c
>@@ -457,11 +457,11 @@ static void remove_watch( DBusWatch *p_watch,
>void *p_data )
> {
>     intf_thread_t *p_intf = (intf_thread_t*) p_data;
>     intf_sys_t    *p_sys  = (intf_sys_t*) p_intf->p_sys;
>-    size_t idx;
> 
>     vlc_mutex_lock( &p_sys->lock );
>-    idx = vlc_array_index_of_item( &p_sys->watches, p_watch );
>-    vlc_array_remove( &p_sys->watches, idx );
>+    ssize_t idx = vlc_array_index_of_item( &p_sys->watches, p_watch );
>+    if( idx >= 0 )
>+        vlc_array_remove( &p_sys->watches, (size_t) idx );
>     vlc_mutex_unlock( &p_sys->lock );
> }
> 
>
>_______________________________________________
>vlc-commits mailing list
>vlc-commits at videolan.org
>https://mailman.videolan.org/listinfo/vlc-commits

WTF is this? This makes zero sense. The value can't be negative since the timeout must be in the list. otherwise we are already in UB.
-- 
Rémi Denis-Courmont


More information about the vlc-devel mailing list