summaryrefslogtreecommitdiff
path: root/capplets/keybindings
diff options
context:
space:
mode:
authorrbuj <[email protected]>2022-01-30 16:24:00 +0100
committerraveit65 <[email protected]>2023-04-14 20:15:21 +0200
commit7a4e5a1ebe46407ebbfa9893049c2d0eb39bed8b (patch)
tree2be2b6325e9a500c08df7647e60135c67747d624 /capplets/keybindings
parente6409a52cd242ec4564585525ff85912cb9c9c61 (diff)
downloadmate-control-center-7a4e5a1ebe46407ebbfa9893049c2d0eb39bed8b.tar.bz2
mate-control-center-7a4e5a1ebe46407ebbfa9893049c2d0eb39bed8b.tar.xz
keybindings: fix memory leak
Diffstat (limited to 'capplets/keybindings')
-rw-r--r--capplets/keybindings/mate-keybinding-properties.c68
1 files changed, 41 insertions, 27 deletions
diff --git a/capplets/keybindings/mate-keybinding-properties.c b/capplets/keybindings/mate-keybinding-properties.c
index b56dd0ac..c3027f7a 100644
--- a/capplets/keybindings/mate-keybinding-properties.c
+++ b/capplets/keybindings/mate-keybinding-properties.c
@@ -412,32 +412,43 @@ typedef struct {
gboolean found;
} KeyMatchData;
-static gboolean key_match(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpointer data)
+static gboolean
+key_match (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data)
{
- KeyMatchData* match_data = data;
- KeyEntry* element = NULL;
+ KeyMatchData *match_data = data;
+ KeyEntry *element;
gchar *element_schema = NULL;
gchar *element_path = NULL;
+ gboolean found = FALSE;
- gtk_tree_model_get(model, iter,
- KEYENTRY_COLUMN, &element,
- -1);
+ gtk_tree_model_get (model, iter,
+ KEYENTRY_COLUMN, &element,
+ -1);
- if (element && element->settings && G_IS_SETTINGS(element->settings))
- {
- g_object_get (element->settings, "schema-id", &element_schema, NULL);
- g_object_get (element->settings, "path", &element_path, NULL);
- }
+ if (!element)
+ return FALSE;
+
+ if (!element->settings || !G_IS_SETTINGS (element->settings))
+ return FALSE;
+
+ g_object_get (element->settings, "schema-id", &element_schema, NULL);
+ g_object_get (element->settings, "path", &element_path, NULL);
- if (element && g_strcmp0(element->gsettings_key, match_data->key) == 0
- && g_strcmp0(element_schema, match_data->schema) == 0
- && g_strcmp0(element_path, match_data->path) == 0)
+ if ((g_strcmp0 (element->gsettings_key, match_data->key) == 0) &&
+ (g_strcmp0 (element_schema, match_data->schema) == 0) &&
+ (g_strcmp0 (element_path, match_data->path) == 0))
{
match_data->found = TRUE;
- return TRUE;
+ found = TRUE;
}
- return FALSE;
+ g_free (element_schema);
+ g_free (element_path);
+
+ return found;
}
static gboolean key_is_already_shown(GtkTreeModel* model, const KeyListEntry* entry)
@@ -529,28 +540,31 @@ ensure_scrollbar (GtkBuilder *builder, int i)
static void
find_section (GtkTreeModel *model,
GtkTreeIter *iter,
- const char *title)
+ const char *title)
{
+ GtkTreeStore *store;
gboolean success;
success = gtk_tree_model_get_iter_first (model, iter);
while (success)
{
- char *description = NULL;
+ char *description;
+ gint res;
gtk_tree_model_get (model, iter,
- DESCRIPTION_COLUMN, &description,
- -1);
-
- if (g_strcmp0 (description, title) == 0)
+ DESCRIPTION_COLUMN, &description,
+ -1);
+ res = g_strcmp0 (description, title);
+ g_free (description);
+ if (res == 0)
return;
success = gtk_tree_model_iter_next (model, iter);
}
-
- gtk_tree_store_append (GTK_TREE_STORE (model), iter, NULL);
- gtk_tree_store_set (GTK_TREE_STORE (model), iter,
- DESCRIPTION_COLUMN, title,
- -1);
+ store = GTK_TREE_STORE (model);
+ gtk_tree_store_append (store, iter, NULL);
+ gtk_tree_store_set (store, iter,
+ DESCRIPTION_COLUMN, title,
+ -1);
}
static void