[gnome-settings-daemon] common: Plug a memory leak when checking installed schemas
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] common: Plug a memory leak when checking installed schemas
- Date: Mon, 7 Sep 2015 14:43:27 +0000 (UTC)
commit 0c5ef3dbb377283528533e7e9f11f77e2134ea3a
Author: Rui Matos <tiagomatos gmail com>
Date: Mon Sep 7 15:26:44 2015 +0200
common: 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
plugins/common/test-plugin.h | 23 ++++++++---------------
1 files changed, 8 insertions(+), 15 deletions(-)
---
diff --git a/plugins/common/test-plugin.h b/plugins/common/test-plugin.h
index 37ad112..9030697 100644
--- a/plugins/common/test-plugin.h
+++ b/plugins/common/test-plugin.h
@@ -34,24 +34,12 @@ static GOptionEntry entries[] = {
};
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)
@@ -59,8 +47,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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]