summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrbuj <[email protected]>2022-01-30 15:49:25 +0100
committermouse <[email protected]>2023-03-31 10:50:44 +0800
commit4be54ce126c7f511f63d5b6d02d3d9a6c3c15f32 (patch)
tree7e91059ac7b9fcaaee4c6bffbfe9565dffc65d0a
parent3382f1ad48abddcb3f235bf0e14f2d0fa48e3dfc (diff)
downloadmate-control-center-4be54ce126c7f511f63d5b6d02d3d9a6c3c15f32.tar.bz2
mate-control-center-4be54ce126c7f511f63d5b6d02d3d9a6c3c15f32.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 67b3e22c..8e8f0b18 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;
}