gvfs: fix possible infinite loop in parse_name_internal()

If none of the closures in the hash table return a non-null value, the
loop never ends. Since the end of the hash table has been reached at
that point, g_hash_table_iter_next() starts asserting.

The possible fix is making the return value of g_hash_table_iter_next()
the condition in the loop.

https://bugzilla.gnome.org/show_bug.cgi?id=768029
This commit is contained in:
Ernestas Kulik 2016-06-25 14:39:54 +03:00 committed by Colin Walters
parent 375b4ca65c
commit f4b5dc30a7

View File

@ -178,11 +178,10 @@ parse_name_internal (GVfs *vfs,
g_rw_lock_reader_lock (&additional_schemes_lock);
g_hash_table_iter_init (&iter, priv->additional_schemes);
while (TRUE)
while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &closure))
{
if (g_hash_table_iter_next (&iter, NULL, (gpointer *) &closure))
ret = closure->parse_name_func (vfs, parse_name,
closure->parse_name_data);
ret = closure->parse_name_func (vfs, parse_name,
closure->parse_name_data);
if (ret)
break;