From f4b5dc30a76569ce4c7e6990c4827407d52a85ef Mon Sep 17 00:00:00 2001 From: Ernestas Kulik Date: Sat, 25 Jun 2016 14:39:54 +0300 Subject: [PATCH] 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 --- gio/gvfs.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gio/gvfs.c b/gio/gvfs.c index 6a02d906b..eed723b0f 100644 --- a/gio/gvfs.c +++ b/gio/gvfs.c @@ -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;