From 61c1e2db99ca25569bdd9231051272ccd26daaa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 28 Jun 2016 03:19:44 +0200 Subject: [PATCH] vfs: Fix copying default schemes list The list of supported schemes is not known at compile-time, so it is wrong to iterate the list with G_N_ELEMENTS() and we miss all but the first scheme. Fix by checking for the %NULL sentinel instead. https://bugzilla.gnome.org/show_bug.cgi?id=768119 --- gio/gvfs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gio/gvfs.c b/gio/gvfs.c index 2fdb0a83b..3beebf4d7 100644 --- a/gio/gvfs.c +++ b/gio/gvfs.c @@ -276,15 +276,14 @@ g_vfs_get_supported_uri_schemes (GVfs *vfs) const char *additional_scheme; GPtrArray *supported_schemes; GHashTableIter iter; - int idx; class = G_VFS_GET_CLASS (vfs); default_schemes = (* class->get_supported_uri_schemes) (vfs); supported_schemes = g_ptr_array_new (); - for (idx = 0; idx < G_N_ELEMENTS (default_schemes); idx++) - g_ptr_array_add (supported_schemes, (gpointer) default_schemes[idx]); + for (; default_schemes && *default_schemes; default_schemes++) + g_ptr_array_add (supported_schemes, (gpointer) *default_schemes); g_rw_lock_reader_lock (&additional_schemes_lock); g_hash_table_iter_init (&iter, priv->additional_schemes);