[Commits] [SCM] claws branch, master, updated. 3.16.0-70-g0d820fa

ticho at claws-mail.org ticho at claws-mail.org
Sat Feb 24 23:29:00 CET 2018


The branch, master has been updated
       via  0d820fab8033d6411759a411d9c314029926c44d (commit)
      from  789fd968bfc3df5647505487e4de6e59ca11ff44 (commit)

Summary of changes:
 src/addrcustomattr.c                    |   10 +++++++++-
 src/edittags.c                          |    7 ++++++-
 src/gtk/gtkutils.c                      |    2 ++
 src/plugins/managesieve/sieve_manager.c |    5 ++++-
 src/prefs_filtering.c                   |    6 ++++--
 src/prefs_send.c                        |    4 ++++
 src/prefs_summaries.c                   |    1 +
 src/prefs_toolbar.c                     |   13 ++++++++++++-
 8 files changed, 42 insertions(+), 6 deletions(-)


- Log -----------------------------------------------------------------
commit 0d820fab8033d6411759a411d9c314029926c44d
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Sat Feb 24 23:27:35 2018 +0100

    Fix memory leaks from results of gtk_tree_model_get().
    
    G_TYPE_STRING values need to be freed, G_TYPE_PIXBUF
    (or anything else derived from GObject) needs to be
    unreferenced. This was forgotten in some places.

diff --git a/src/addrcustomattr.c b/src/addrcustomattr.c
index d3f97d5..6997f60 100644
--- a/src/addrcustomattr.c
+++ b/src/addrcustomattr.c
@@ -103,6 +103,7 @@ static gint custom_attr_cmp_func (GtkTreeModel *model, GtkTreeIter *a,
 								  GtkTreeIter *b, gpointer userdata)
  {
 	gchar *name1, *name2;
+	gint res;
 
 	gtk_tree_model_get(model, a, CUSTOM_ATTR_NAME, &name1, -1);
 	gtk_tree_model_get(model, b, CUSTOM_ATTR_NAME, &name2, -1);
@@ -113,7 +114,11 @@ static gint custom_attr_cmp_func (GtkTreeModel *model, GtkTreeIter *a,
 	if (name2 == NULL)
 		return 1;
 	
-	return g_utf8_collate(name1, name2);
+	res = g_utf8_collate(name1, name2);
+	g_free(name1);
+	g_free(name2);
+
+	return res;
 }
 
 static GtkListStore* custom_attr_window_create_data_store(void)
@@ -347,8 +352,10 @@ static gboolean find_attr_in_store(GtkTreeModel *model,
 	if (g_utf8_collate(data->attr, attr)==0) {
 		data->path = path; /* signal we found it */
 		data->iter = *iter;
+		g_free(attr);
 		return TRUE;
 	}
+	g_free(attr);
 	return FALSE; 
 }
 
@@ -580,6 +587,7 @@ static gboolean custom_attr_store_to_glist (GtkTreeModel *model,
 	gtk_tree_model_get(model, iter, CUSTOM_ATTR_NAME, &attr, -1);
 	if (attr) {
 		store_to_glist = g_list_prepend(store_to_glist, g_strdup(attr));
+		g_free(attr);
 	}
 	return FALSE;
 }
diff --git a/src/edittags.c b/src/edittags.c
index 1209dd0..c559102 100644
--- a/src/edittags.c
+++ b/src/edittags.c
@@ -59,6 +59,7 @@ enum {
 static gint tag_cmp_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata)
  {
 	gchar *name1, *name2;
+	gint res;
 
 	gtk_tree_model_get(model, a, TAG_NAME, &name1, -1);
 	gtk_tree_model_get(model, b, TAG_NAME, &name2, -1);
@@ -69,7 +70,11 @@ static gint tag_cmp_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, g
 	if (name2 == NULL)
 		return 1;
 	
-	return g_utf8_collate(name1,name2);
+	res = g_utf8_collate(name1,name2);
+	g_free(name1);
+	g_free(name2);
+
+	return res;
 }
 
 static void apply_window_create(void);
diff --git a/src/gtk/gtkutils.c b/src/gtk/gtkutils.c
index 7aa5167..a933471 100644
--- a/src/gtk/gtkutils.c
+++ b/src/gtk/gtkutils.c
@@ -1508,12 +1508,14 @@ gboolean gtkut_tree_model_text_iter_prev(GtkTreeModel *model,
 		gtk_tree_model_get(model, &cur_iter, 0, &cur_value, -1);
 
 		if (strcmp(text, cur_value) == 0) {
+			g_free(cur_value);
 			if (count <= 0)
 				return FALSE;
 
 			return gtk_tree_model_iter_nth_child(model, iter, NULL, count - 1);
 		}
 
+		g_free(cur_value);
 		valid = gtk_tree_model_iter_next(model, &cur_iter);
 		count++;
 	}
diff --git a/src/plugins/managesieve/sieve_manager.c b/src/plugins/managesieve/sieve_manager.c
index 7635c8b..8a9af4c 100644
--- a/src/plugins/managesieve/sieve_manager.c
+++ b/src/plugins/managesieve/sieve_manager.c
@@ -186,11 +186,12 @@ static void filter_edit(GtkWidget *widget, SieveManagerPage *page)
 {
 	SieveEditorPage *editor;
 	SieveSession *session = page->active_session;
+	gchar *filter_name;
 
 	if (!session)
 		return;
 
-	gchar *filter_name = filters_list_get_selected_filter(page->filters_list);
+	filter_name = filters_list_get_selected_filter(page->filters_list);
 	if (!filter_name)
 		return;
 
@@ -202,6 +203,8 @@ static void filter_edit(GtkWidget *widget, SieveManagerPage *page)
 		sieve_editor_load(editor,
 			(sieve_session_cb_fn)filter_got_load_error, page);
 	}
+
+	g_free(filter_name);
 }
 
 static void filter_renamed(SieveSession *session, gboolean abort,
diff --git a/src/prefs_filtering.c b/src/prefs_filtering.c
index d18aed1..8424ff8 100644
--- a/src/prefs_filtering.c
+++ b/src/prefs_filtering.c
@@ -957,7 +957,6 @@ static void prefs_filtering_set_list(void)
 					filtering.cond_list_view, row,
 					&enabled, &name, &account_id);
 			prop = matcher_parser_get_filtering(filtering_str);
-			g_free(filtering_str);
 			if (prop) {
 				prop->enabled = enabled;
 				if (prop->name != NULL)
@@ -968,7 +967,8 @@ static void prefs_filtering_set_list(void)
 					g_slist_append(prefs_filtering, prop);
 			}
 		}
-		
+
+		g_free(filtering_str);
 		row++;
 	}				
 	
@@ -1183,6 +1183,7 @@ static void prefs_filtering_substitute_cb(gpointer action, gpointer data)
 	prefs_filtering_list_view_get_rule_info(
 			filtering.cond_list_view, selected_row,
 			&enabled, &name, &account_id);
+	g_free(name); /* We're not using this. */
 	prop->enabled = enabled;
 
 	prefs_filtering_list_view_set_row(selected_row, prop);
@@ -1263,6 +1264,7 @@ static void prefs_filtering_duplicate_cb(gpointer action, gpointer data)
 	prefs_filtering_list_view_get_rule_info(
 			filtering.cond_list_view, selected_row,
 			&enabled, &name, &account_id);
+	g_free(name); /* We're not using this. */
 	prop->enabled = enabled;
 
 	prefs_filtering_list_view_set_row(-selected_row-2, prop);
diff --git a/src/prefs_send.c b/src/prefs_send.c
index 53677eb..811e68b 100644
--- a/src/prefs_send.c
+++ b/src/prefs_send.c
@@ -91,9 +91,11 @@ static gboolean _select_by_data_func(GtkTreeModel *model, GtkTreePath *path,
 	gtk_tree_model_get(GTK_TREE_MODEL(model), iter, COMBOBOX_DATA, &curdata, -1);
 	if ( data != NULL && curdata != NULL && !strcmp(data, curdata) ) {
 		gtk_combo_box_set_active_iter(combobox, iter);
+		g_free(curdata);
 		return TRUE;
 	}
 
+	g_free(curdata);
 	return FALSE;
 }
 
@@ -126,6 +128,8 @@ static gboolean _combobox_separator_func(GtkTreeModel *model,
 
 	if( txt == NULL )
 		return TRUE;
+
+	g_free(txt);
 	return FALSE;
 }
 
diff --git a/src/prefs_summaries.c b/src/prefs_summaries.c
index 27f07d5..16ae791 100644
--- a/src/prefs_summaries.c
+++ b/src/prefs_summaries.c
@@ -889,6 +889,7 @@ static void date_format_select_row(GtkTreeView *list_view,
 	strncpy(new_format, old_format, cur_pos);
 	new_format[cur_pos] = '\0';
 	strcat(new_format, format);
+	g_free(format);
 	strcat(new_format, &old_format[cur_pos]);
 
 	gtk_entry_set_text(GTK_ENTRY(datefmt_sample), new_format);
diff --git a/src/prefs_toolbar.c b/src/prefs_toolbar.c
index 4586cf3..cc56483 100644
--- a/src/prefs_toolbar.c
+++ b/src/prefs_toolbar.c
@@ -1319,7 +1319,8 @@ static void set_visible_if_not_text(GtkTreeViewColumn *col,
 				   -1);
 		/* note getting a pixbuf from a tree model increases
 		 * its refcount ... */
-		g_object_unref(pixbuf);
+		if (pixbuf != NULL)
+			g_object_unref(pixbuf);
 
 		g_object_set(renderer, "visible", TRUE, NULL);
 		g_object_set(renderer, "pixbuf",  pixbuf, NULL);
@@ -1437,6 +1438,8 @@ static gboolean set_list_selected(GtkTreeSelection *selector,
 					ITEM_SEPARATOR);
 		g_free(icon_text);
 		g_free(descr);
+		if (pix != NULL)
+			g_object_unref(pix);
 
 		return TRUE;
 	}
@@ -1473,6 +1476,8 @@ static gboolean set_list_selected(GtkTreeSelection *selector,
 
 		g_free(icon_text);
 		g_free(descr);
+		if (pix != NULL)
+			g_object_unref(pix);
 
 		return TRUE;
 	}
@@ -1488,6 +1493,8 @@ static gboolean set_list_selected(GtkTreeSelection *selector,
 
 		g_free(descr);
 		g_free(icon_text);
+		if (pix != NULL)
+			g_object_unref(pix);
 		return TRUE;
 	}
 
@@ -1513,6 +1520,8 @@ static gboolean set_list_selected(GtkTreeSelection *selector,
 
 	g_free(icon_text);
 	g_free(descr);
+	if (pix != NULL)
+		g_object_unref(pix);
 
 	return TRUE;
 }
@@ -1548,6 +1557,8 @@ static void icon_chooser_ok_clicked(GtkButton *button,
 	prefs_toolbar->item_icon_file = icon_file;
 	gtk_button_set_image(GTK_BUTTON(prefs_toolbar->icon_button),
 			     gtk_image_new_from_pixbuf(pix));
+	if (pix != NULL)
+		g_object_unref(pix);
 
 	gtk_widget_destroy(prefs_toolbar->icon_chooser_win);
 	prefs_toolbar->icon_chooser_win = NULL;

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list