summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRui Matos <tiagomatos@gmail.com>2015-09-07 15:23:35 +0200
committerRui Matos <tiagomatos@gmail.com>2015-09-07 15:51:15 +0200
commit7eabee705df7230643dee245b438d3aaa19d442b (patch)
treed8a7c7b802dcfc2b2a3b61a497dd139d53e56b94
parenta0eb98f20eedf127579d9a2d2413c9b7471710c3 (diff)
downloadgnome-settings-daemon-7eabee705df7230643dee245b438d3aaa19d442b.tar.gz
keyboard: 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
-rw-r--r--plugins/keyboard/gsd-keyboard-manager.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/plugins/keyboard/gsd-keyboard-manager.c b/plugins/keyboard/gsd-keyboard-manager.c
index e7117c25..eb75c928 100644
--- a/plugins/keyboard/gsd-keyboard-manager.c
+++ b/plugins/keyboard/gsd-keyboard-manager.c
@@ -122,24 +122,12 @@ init_builder_with_sources (GVariantBuilder *builder,
}
static gboolean
-contained (char **items,
- const char *item)
-{
- while (*items) {
- if (g_strcmp0 (*items++, item) == 0) {
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-static gboolean
schema_is_installed (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)
@@ -147,8 +135,13 @@ schema_is_installed (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