[gnome-settings-daemon] daemon: Plug a memory leak when checking installed schemas



commit 9982541a01b4cbbe6f70f4c68730c2f5e89a0fd1
Author: Rui Matos <tiagomatos gmail com>
Date:   Mon Sep 7 15:26:19 2015 +0200

    daemon: Plug a memory leak when checking installed schemas
    
    g_settings_schema_source_list_schemas() returns allocated string
    arrays that must be freed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=754681

 gnome-settings-daemon/gnome-settings-manager.c |   25 ++++++++---------------
 1 files changed, 9 insertions(+), 16 deletions(-)
---
diff --git a/gnome-settings-daemon/gnome-settings-manager.c b/gnome-settings-daemon/gnome-settings-manager.c
index 8658988..07fff29 100644
--- a/gnome-settings-daemon/gnome-settings-manager.c
+++ b/gnome-settings-daemon/gnome-settings-manager.c
@@ -182,24 +182,12 @@ on_plugin_deactivated (GnomeSettingsPluginInfo *info,
 }
 
 static gboolean
-contained (char       **items,
-           const char  *item)
-{
-        while (*items) {
-                if (g_strcmp0 (*items++, item) == 0) {
-                        return TRUE;
-                }
-        }
-
-        return FALSE;
-}
-
-static gboolean
 is_schema (const char *schema)
 {
         GSettingsSchemaSource *source = NULL;
         gchar **non_relocatable = NULL;
         gchar **relocatable = NULL;
+        gboolean installed = FALSE;
 
         source = g_settings_schema_source_get_default ();
         if (!source)
@@ -207,8 +195,13 @@ is_schema (const char *schema)
 
         g_settings_schema_source_list_schemas (source, TRUE, &non_relocatable, &relocatable);
 
-        return (contained (non_relocatable, schema) ||
-                contained (relocatable, schema));
+        if (g_strv_contains ((const gchar * const *)non_relocatable, schema) ||
+            g_strv_contains ((const gchar * const *)relocatable, schema))
+                installed = TRUE;
+
+        g_strfreev (non_relocatable);
+        g_strfreev (relocatable);
+        return installed;
 }
 
 static gboolean
@@ -220,7 +213,7 @@ is_whitelisted (char       **whitelist,
             g_strcmp0 (whitelist[0], "all") == 0)
                 return TRUE;
 
-        return contained (whitelist, plugin_name);
+        return g_strv_contains ((const gchar * const *)whitelist, plugin_name);
 }
 
 static void


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