summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrbuj <[email protected]>2022-01-30 15:49:25 +0100
committerraveit65 <[email protected]>2023-05-07 17:11:53 +0200
commit8fbf599c024d0c7eb787b2f23dd141befaab4251 (patch)
treeb968f2db1d6f6b5266464caf649b6221d776d0be
parent62385ba63409e647381c04dbd7a647d3018d777f (diff)
downloadmate-control-center-8fbf599c024d0c7eb787b2f23dd141befaab4251.tar.bz2
mate-control-center-8fbf599c024d0c7eb787b2f23dd141befaab4251.tar.xz
keyboard: fix memory leak
-rw-r--r--capplets/keyboard/mate-keyboard-properties-xkbmc.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/capplets/keyboard/mate-keyboard-properties-xkbmc.c b/capplets/keyboard/mate-keyboard-properties-xkbmc.c
index 6ffc69e6..1fb73e87 100644
--- a/capplets/keyboard/mate-keyboard-properties-xkbmc.c
+++ b/capplets/keyboard/mate-keyboard-properties-xkbmc.c
@@ -43,27 +43,30 @@ static void fill_models_list (GtkBuilder * chooser_dialog);
static gboolean fill_vendors_list (GtkBuilder * chooser_dialog);
static GtkTreePath *
-gtk_list_store_find_entry (GtkListStore * list_store,
- GtkTreeIter * iter, gchar * name, int column_id)
+gtk_list_store_find_entry (GtkListStore *list_store,
+ GtkTreeIter *iter,
+ gchar *name,
+ int column_id)
{
- GtkTreePath *path;
- char *current_name = NULL;
- if (gtk_tree_model_get_iter_first
- (GTK_TREE_MODEL (list_store), iter)) {
- do {
- gtk_tree_model_get (GTK_TREE_MODEL
- (list_store), iter, column_id,
- &current_name, -1);
- if (!g_ascii_strcasecmp (name, current_name)) {
- path =
- gtk_tree_model_get_path
- (GTK_TREE_MODEL (list_store), iter);
- return path;
- }
- g_free (current_name);
- } while (gtk_tree_model_iter_next
- (GTK_TREE_MODEL (list_store), iter));
- }
+ GtkTreeModel *tree_model = GTK_TREE_MODEL (list_store);
+
+ if (!gtk_tree_model_get_iter_first (tree_model, iter))
+ return NULL;
+
+ do {
+ char *current_name;
+ gint res;
+
+ gtk_tree_model_get (tree_model, iter,
+ column_id, &current_name,
+ -1);
+ res = g_ascii_strcasecmp (name, current_name);
+ g_free (current_name);
+ if (res == 0) {
+ return gtk_tree_model_get_path (tree_model, iter);
+ }
+ } while (gtk_tree_model_iter_next (tree_model, iter));
+
return NULL;
}