[Commits] [SCM] claws branch, gtk3, updated. 4.0.0-166-g24415eb70

wwp at claws-mail.org wwp at claws-mail.org
Sun Sep 12 13:41:35 CEST 2021


The branch, gtk3 has been updated
       via  24415eb70d1e92081ca8013fafb78679e4e2025f (commit)
      from  e97569bcbc0861a6846a11492789ada403a41089 (commit)

Summary of changes:
 src/main.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)


- Log -----------------------------------------------------------------
commit 24415eb70d1e92081ca8013fafb78679e4e2025f
Author: wwp <subscript at free.fr>
Date:   Sun Sep 12 13:40:06 2021 +0200

    Fix CID 1491070: resource leak. Use a static GString to feed cmd.mailto
    instead of a dynamically allocated struct that will never be freed.

diff --git a/src/main.c b/src/main.c
index abb2a4e92..e53ccd50e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1824,10 +1824,9 @@ static void exit_claws(MainWindow *mainwin)
 		exit(1);	\
 	}
 
-static GString * parse_cmd_compose_from_file(const gchar *fn)
+static void parse_cmd_compose_from_file(const gchar *fn, GString *body)
 {
 	GString *headers = g_string_new(NULL);
-	GString *body = g_string_new(NULL);
 	gchar *to = NULL;
 	gchar *h;
 	gchar *v;
@@ -1884,8 +1883,6 @@ static GString * parse_cmd_compose_from_file(const gchar *fn)
 	/* append the remaining headers */
 	g_string_append(body, headers->str);
 	g_string_free(headers, TRUE);
-
-	return body;
 }
 
 #undef G_PRINT_EXIT
@@ -1902,6 +1899,8 @@ static void parse_cmd_opt_error(char *errstr, char* optstr)
 	exit(1);
 }
 
+static GString mailto; /* used to feed cmd.compose_mailto when --compose-from-file is used */
+
 static void parse_cmd_opt(int argc, char *argv[])
 {
 	AttachInfo *ainfo;
@@ -1920,9 +1919,9 @@ static void parse_cmd_opt(int argc, char *argv[])
 		    if (i+1 < argc) {
 				const gchar *p = argv[i+1];
 
-				GString *mailto = parse_cmd_compose_from_file(p);
+				parse_cmd_compose_from_file(p, &mailto);
 				cmd.compose = TRUE;
-				cmd.compose_mailto = mailto->str;
+				cmd.compose_mailto = mailto.str;
 				i++;
 		    } else {
                 parse_cmd_opt_error(_("Missing file argument for option %s"), argv[i]);

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list