[Commits] [SCM] claws branch, master, updated. 3.18.0-162-gfc73942fc

wwp at claws-mail.org wwp at claws-mail.org
Sun Sep 26 18:54:29 CEST 2021


The branch, master has been updated
       via  fc73942fc655111d25e097a02609c9ffa5cbf061 (commit)
      from  c771663a2ee1618348c8233ef6d465306b1136f2 (commit)

Summary of changes:
 src/toolbar.c | 44 ++++++++++++++++++++++++++++++++++----------
 src/toolbar.h |  8 +++-----
 2 files changed, 37 insertions(+), 15 deletions(-)


- Log -----------------------------------------------------------------
commit fc73942fc655111d25e097a02609c9ffa5cbf061
Author: wwp <subscript at free.fr>
Date:   Sun Sep 26 18:53:49 2021 +0200

    Fix CID 1491320, 1492199, 1492201: resource leaks.

diff --git a/src/toolbar.c b/src/toolbar.c
index 4de56a8c4..ed3226161 100644
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -479,10 +479,15 @@ static void toolbar_parse_item(XMLFile *file, ToolbarType source, gboolean *rewr
 		attr = g_list_next(attr);
 	}
 	if (item->index != -1) {
-		if (!toolbar_is_duplicate(item->index, source)) 
+		if (!toolbar_is_duplicate(item->index, source))  {
 			toolbar_config[source].item_list = g_slist_append(toolbar_config[source].item_list,
 									 item);
-	}
+		} else {
+			toolbar_item_destroy(item);
+		}        
+	} else {
+		toolbar_item_destroy(item);
+	}    
 }
 
 const gchar *toolbar_get_short_text(int action) {
@@ -636,10 +641,15 @@ static void toolbar_set_default_generic(ToolbarType toolbar_type, DefaultToolbar
 		}
 
 		if (toolbar_item->index != -1) {
-			if (!toolbar_is_duplicate(toolbar_item->index, toolbar_type)) 
+			if (!toolbar_is_duplicate(toolbar_item->index, toolbar_type)) {
 				toolbar_config[toolbar_type].item_list = 
 					g_slist_append(toolbar_config[toolbar_type].item_list, toolbar_item);
-		}	
+			} else {
+				toolbar_item_destroy(toolbar_item);
+			}
+		} else {
+			toolbar_item_destroy(toolbar_item);
+		}
 	}
 }
 
@@ -765,10 +775,12 @@ void toolbar_save_config_file(ToolbarType source)
 		
 fail:
 		FILE_OP_ERROR(fileSpec, "fprintf");
-		g_free( fileSpec );
+		g_free(fileSpec);
 		prefs_file_close_revert (pfile);
-	} else
+	} else {
+		g_free(fileSpec);
 		g_warning("failed to open toolbar configuration file for writing");
+	}
 }
 
 void toolbar_read_config_file(ToolbarType source)
@@ -850,9 +862,7 @@ void toolbar_clear_list(ToolbarType source)
 		toolbar_config[source].item_list = 
 			g_slist_remove(toolbar_config[source].item_list, item);
 
-		g_free(item->file);
-		g_free(item->text);
-		g_free(item);	
+		toolbar_item_destroy(item);	
 	}
 	g_slist_free(toolbar_config[source].item_list);
 }
@@ -2645,7 +2655,8 @@ Toolbar *toolbar_create(ToolbarType 	 type,
 #define UNREF_ICON(icon) if (toolbar->icon != NULL) \
 			g_object_unref(toolbar->icon)
 
-void toolbar_destroy(Toolbar * toolbar) {
+void toolbar_destroy(Toolbar * toolbar)
+{
 	UNREF_ICON(compose_mail_icon);
 	UNREF_ICON(compose_news_icon);
 	UNREF_ICON(learn_spam_icon);
@@ -2656,6 +2667,19 @@ void toolbar_destroy(Toolbar * toolbar) {
 
 #undef UNREF_ICON
 
+void toolbar_item_destroy(ToolbarItem *item)
+{
+	cm_return_if_fail(item != NULL);
+
+	if (item) {
+		if (item->file) \
+			g_free(item->file); \
+		if (item->text) \
+			g_free(item->text); \
+		g_free(item);\
+	}
+}
+
 void toolbar_update(ToolbarType type, gpointer data)
 {
 	Toolbar *toolbar_data;
diff --git a/src/toolbar.h b/src/toolbar.h
index becf734a2..89ffe1d97 100644
--- a/src/toolbar.h
+++ b/src/toolbar.h
@@ -127,11 +127,7 @@ struct _ToolbarItem {
 	while (item_list != NULL) { \
 		item = (ToolbarItem*)item_list->data; \
 		item_list = g_slist_remove(item_list, item); \
-		if (item->file) \
-			g_free(item->file); \
-		if (item->text) \
-			g_free(item->text); \
-		g_free(item);\
+		toolbar_item_destroy(item); \
 	}\
 	g_slist_free(item_list);\
 }
@@ -282,6 +278,8 @@ void	toolbar_set_style		(GtkWidget	*toolbar_wid,
 					 GtkWidget	*handlebox_wid,
 					 guint		 action);
 void 	toolbar_destroy			(Toolbar	*toolbar);
+void 	toolbar_item_destroy		(ToolbarItem	*toolbar_item);
+
 void toolbar_set_learn_button		(Toolbar	*toolbar, 
 					 LearnButtonType  learn_btn_type);
 const gchar *toolbar_get_short_text	(int action);

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list