[Commits] [SCM] claws branch, master, updated. 3.17.3-36-g7efc008

ticho at claws-mail.org ticho at claws-mail.org
Mon Jan 7 17:38:45 CET 2019


The branch, master has been updated
       via  7efc008db2cb63dc7d4ac0f0c7f9046742ceae49 (commit)
      from  f4f722b814ad7ff6f3fa6cb5e83b330275784d97 (commit)

Summary of changes:
 src/common/utils.c |   20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)


- Log -----------------------------------------------------------------
commit 7efc008db2cb63dc7d4ac0f0c7f9046742ceae49
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Mon Jan 7 17:38:01 2019 +0100

    Fix a few small memory leaks in scan_mailto_url()

diff --git a/src/common/utils.c b/src/common/utils.c
index ec87994..110817a 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -1411,7 +1411,8 @@ gint scan_mailto_url(const gchar *mailto, gchar **from, gchar **to, gchar **cc,
 					  "../",
 					  NULL };
 	gint num_attach = 0;
-	gchar **my_att = NULL;
+
+	cm_return_val_if_fail(mailto != NULL, -1);
 
 	Xstrdup_a(tmp_mailto, mailto, return -1);
 
@@ -1427,9 +1428,6 @@ gint scan_mailto_url(const gchar *mailto, gchar **from, gchar **to, gchar **cc,
 	if (to && !*to)
 		*to = decode_uri_gdup(tmp_mailto);
 
-	my_att = g_malloc(sizeof(char *));
-	my_att[0] = NULL;
-
 	while (p) {
 		gchar *field, *value;
 
@@ -1456,6 +1454,7 @@ gint scan_mailto_url(const gchar *mailto, gchar **from, gchar **to, gchar **cc,
 			} else {
 				gchar *tmp = decode_uri_gdup(value);
 				gchar *new_from = g_strdup_printf("%s, %s", *from, tmp);
+				g_free(tmp);
 				g_free(*from);
 				*from = new_from;
 			}
@@ -1465,6 +1464,7 @@ gint scan_mailto_url(const gchar *mailto, gchar **from, gchar **to, gchar **cc,
 			} else {
 				gchar *tmp = decode_uri_gdup(value);
 				gchar *new_cc = g_strdup_printf("%s, %s", *cc, tmp);
+				g_free(tmp);
 				g_free(*cc);
 				*cc = new_cc;
 			}
@@ -1474,6 +1474,7 @@ gint scan_mailto_url(const gchar *mailto, gchar **from, gchar **to, gchar **cc,
 			} else {
 				gchar *tmp = decode_uri_gdup(value);
 				gchar *new_bcc = g_strdup_printf("%s, %s", *bcc, tmp);
+				g_free(tmp);
 				g_free(*bcc);
 				*bcc = new_bcc;
 			}
@@ -1491,11 +1492,16 @@ gint scan_mailto_url(const gchar *mailto, gchar **from, gchar **to, gchar **cc,
 		} else if (attach && !g_ascii_strcasecmp(field, "attach")) {
 			int i = 0;
 			gchar *tmp = decode_uri_gdup(value);
+			gchar **my_att = g_malloc(sizeof(char *));
+
+			my_att[0] = NULL;
+
 			for (; forbidden_uris[i]; i++) {
 				if (strstr(tmp, forbidden_uris[i])) {
 					g_print("Refusing to attach '%s', potential private data leak\n",
 							tmp);
 					g_free(tmp);
+					g_free(my_att);
 					break;
 				}
 			}
@@ -1505,6 +1511,10 @@ gint scan_mailto_url(const gchar *mailto, gchar **from, gchar **to, gchar **cc,
 				my_att = g_realloc(my_att, (sizeof(char *))*(num_attach+1));
 				my_att[num_attach-1] = tmp;
 				my_att[num_attach] = NULL;
+				*attach = my_att;
+				g_free(tmp);
+			} else {
+				g_free(my_att);
 			}
 		} else if (inreplyto && !*inreplyto &&
 			   !g_ascii_strcasecmp(field, "in-reply-to")) {
@@ -1512,8 +1522,6 @@ gint scan_mailto_url(const gchar *mailto, gchar **from, gchar **to, gchar **cc,
 		}
 	}
 
-	if (attach)
-		*attach = my_att;
 	return 0;
 }
 

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list