[vlc-commits] vlc_arrays: fix vlc_dictionary_has_key

Francois Cartegnie git at videolan.org
Sun Apr 23 15:45:40 CEST 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sun Apr 23 15:39:37 2017 +0200| [4cee7fe3238cf1ce2c382abc47a3a70b5190eb49] | committer: Francois Cartegnie

vlc_arrays: fix vlc_dictionary_has_key

broken untested function went under the radar
and is testing index from hash instead of key.
50% false positive due to hash % size pos.

fixes random behaviour in ttml #18250
and probably playlist fetcher, dbus control

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

 include/vlc_arrays.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/vlc_arrays.h b/include/vlc_arrays.h
index dcdfa7a556..b9fa33df93 100644
--- a/include/vlc_arrays.h
+++ b/include/vlc_arrays.h
@@ -432,7 +432,13 @@ vlc_dictionary_has_key( const vlc_dictionary_t * p_dict, const char * psz_key )
         return 0;
 
     int i_pos = DictHash( psz_key, p_dict->i_size );
-    return p_dict->p_entries[i_pos] != NULL;
+    const vlc_dictionary_entry_t * p_entry = p_dict->p_entries[i_pos];
+    for( ; p_entry != NULL; p_entry = p_entry->p_next )
+    {
+        if( !strcmp( psz_key, p_entry->psz_key ) )
+            break;
+    }
+    return p_entry != NULL;
 }
 
 static inline void *



More information about the vlc-commits mailing list