[Commits] [SCM] claws branch, master, updated. 3.18.0-186-g8856d58a4

wwp at claws-mail.org wwp at claws-mail.org
Tue Sep 28 14:38:07 CEST 2021


The branch, master has been updated
       via  8856d58a488acc87089c85122f3235bbd32a5006 (commit)
      from  415e7de0d1587ea0fe323b9eadbbc2f163eb97d2 (commit)

Summary of changes:
 src/plugins/spamassassin/spamassassin.c | 96 +++++++++++++++++----------------
 1 file changed, 50 insertions(+), 46 deletions(-)


- Log -----------------------------------------------------------------
commit 8856d58a488acc87089c85122f3235bbd32a5006
Author: wwp <subscript at free.fr>
Date:   Tue Sep 28 14:36:55 2021 +0200

    Fix CID 1491076 and 1491352: resource leaks.

diff --git a/src/plugins/spamassassin/spamassassin.c b/src/plugins/spamassassin/spamassassin.c
index 3166c3937..dedbe96e4 100644
--- a/src/plugins/spamassassin/spamassassin.c
+++ b/src/plugins/spamassassin/spamassassin.c
@@ -1,6 +1,6 @@
 /*
  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2012 the Claws Mail Team
+ * Copyright (C) 1999-2021 the Claws Mail Team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -418,6 +418,7 @@ int spamassassin_learn(MsgInfo *msginfo, GSList *msglist, gboolean spam)
 		return -1;
 	}
 
+	/* process *either* a msginfo or a msglist */
 	if (msginfo) {
 		file = procmsg_get_message_file(msginfo);
 		if (file == NULL) {
@@ -435,53 +436,55 @@ int spamassassin_learn(MsgInfo *msginfo, GSList *msglist, gboolean spam)
 							prefs_common_get_prefs()->work_offline?" -L":"",
 							spam?"--spam":"--ham", file);
 		}
-	}
-	if (msglist) {
-		GSList *cur = msglist;
-		MsgInfo *info;
-
-		if (config.transport == SPAMASSASSIN_TRANSPORT_TCP) {
-			/* execute n-times the spamc command */
-			for (; cur; cur = cur->next) {
-				info = (MsgInfo *)cur->data;
-				gchar *tmpcmd = NULL;
-				gchar *tmpfile = get_tmp_file();
-
-				if (spamc_wrapper == NULL) {
-					spamc_wrapper = spamassassin_create_tmp_spamc_wrapper(spam);
-				}
+	} else {
+		if (msglist) {
+			GSList *cur = msglist;
+			MsgInfo *info;
+
+			if (config.transport == SPAMASSASSIN_TRANSPORT_TCP) {
+				/* execute n-times the spamc command */
+				for (; cur; cur = cur->next) {
+					info = (MsgInfo *)cur->data;
+					gchar *tmpcmd = NULL;
+					gchar *tmpfile = get_tmp_file();
+
+					if (spamc_wrapper == NULL) {
+						spamc_wrapper = spamassassin_create_tmp_spamc_wrapper(spam);
+					}
 
-				if (spamc_wrapper && tmpfile &&
-			    	copy_file(procmsg_get_message_file(info), tmpfile, TRUE) == 0) {
-					tmpcmd = g_strconcat(shell?shell:"sh", " ", spamc_wrapper, " ",
-										tmpfile, NULL);
-					debug_print("%s\n", tmpcmd);
-					execute_command_line(tmpcmd, FALSE, NULL);
-					g_free(tmpcmd);
+					if (spamc_wrapper && tmpfile &&
+				    	copy_file(procmsg_get_message_file(info), tmpfile, TRUE) == 0) {
+						tmpcmd = g_strconcat(shell?shell:"sh", " ", spamc_wrapper, " ",
+											tmpfile, NULL);
+						debug_print("%s\n", tmpcmd);
+						execute_command_line(tmpcmd, FALSE, NULL);
+						g_free(tmpcmd);
+					}
+					g_free(tmpfile);
 				}
-				g_free(tmpfile);
-			}
-			g_free(spamc_wrapper);
-			return 0;
-		} else {
-			cmd = g_strdup_printf("sa-learn -u %s%s %s",
-					config.username,
-					prefs_common_get_prefs()->work_offline?" -L":"",
-					spam?"--spam":"--ham");
-
-			/* concatenate all message tmpfiles to the sa-learn command-line */
-			for (; cur; cur = cur->next) {
-				info = (MsgInfo *)cur->data;
-				gchar *tmpcmd = NULL;
-				gchar *tmpfile = get_tmp_file();
-
-				if (tmpfile &&
-			    	copy_file(procmsg_get_message_file(info), tmpfile, TRUE) == 0) {			
-					tmpcmd = g_strconcat(cmd, " ", tmpfile, NULL);
-					g_free(cmd);
-					cmd = tmpcmd;
+				if (spamc_wrapper)
+					g_free(spamc_wrapper);
+				return 0;
+			} else {
+				cmd = g_strdup_printf("sa-learn -u %s%s %s",
+						config.username,
+						prefs_common_get_prefs()->work_offline?" -L":"",
+						spam?"--spam":"--ham");
+
+				/* concatenate all message tmpfiles to the sa-learn command-line */
+				for (; cur; cur = cur->next) {
+					info = (MsgInfo *)cur->data;
+					gchar *tmpcmd = NULL;
+					gchar *tmpfile = get_tmp_file();
+
+					if (tmpfile &&
+				    	copy_file(procmsg_get_message_file(info), tmpfile, TRUE) == 0) {			
+						tmpcmd = g_strconcat(cmd, " ", tmpfile, NULL);
+						g_free(cmd);
+						cmd = tmpcmd;
+					}
+					g_free(tmpfile);
 				}
-				g_free(tmpfile);
 			}
 		}
 	}
@@ -492,7 +495,8 @@ int spamassassin_learn(MsgInfo *msginfo, GSList *msglist, gboolean spam)
 	/* only run sync calls to sa-learn/spamc to prevent system lockdown */
 	execute_command_line(cmd, FALSE, NULL);
 	g_free(cmd);
-	g_free(spamc_wrapper);
+	if (spamc_wrapper)
+		g_free(spamc_wrapper);
 
 	return 0;
 }

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list