[glib] vfs: Fix copying default schemes list



commit 61c1e2db99ca25569bdd9231051272ccd26daaa2
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Jun 28 03:19:44 2016 +0200

    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 files changed, 2 insertions(+), 3 deletions(-)
---
diff --git a/gio/gvfs.c b/gio/gvfs.c
index 2fdb0a8..3beebf4 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]