[Commits] [SCM] claws branch, master, updated. 3.15.0-94-g814b087

ticho at claws-mail.org ticho at claws-mail.org
Tue Jul 11 18:40:30 CEST 2017


The branch, master has been updated
       via  814b087c9100bd6820bd67f8502286517f37de75 (commit)
      from  4311a38be85f5054a22c5be5605720fce867421d (commit)

Summary of changes:
 src/compose.c        |   34 ++++++++++++++++++++++++++++++++++
 src/prefs_template.c |    2 ++
 src/quote_fmt.h      |    1 +
 3 files changed, 37 insertions(+)


- Log -----------------------------------------------------------------
commit 814b087c9100bd6820bd67f8502286517f37de75
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Tue Jul 11 18:37:54 2017 +0200

    Fix several memory leaks around template parsing.
    
    FLEX-generated quote_fmt_scan_string() allocates a buffer
    (and actually returns a pointer to it, although its prototype
    in quote_fmt.h says its return value is void), which needs
    to be cleaned up afterwards.

diff --git a/src/compose.c b/src/compose.c
index 21e690a..4dfb962 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -1084,6 +1084,7 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
 			else
 				gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
 			quote_fmt_reset_vartable();
+			quote_fmtlex_destroy();
 
 			g_free(tmp);
 		}
@@ -1177,6 +1178,7 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
 				gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), buf);
 			compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
 			quote_fmt_reset_vartable();
+			quote_fmtlex_destroy();
 
 			g_free(subject);
 			g_free(tmp);
@@ -1652,6 +1654,7 @@ static Compose *compose_generic_reply(MsgInfo *msginfo,
 		else
 			gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
 		quote_fmt_reset_vartable();
+		quote_fmtlex_destroy();
 
 		g_free(tmp);
 	}
@@ -1834,6 +1837,7 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
 		else
 			gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
 		quote_fmt_reset_vartable();
+		quote_fmtlex_destroy();
 
 		g_free(tmp);
 		procmsg_msginfo_free(&full_msginfo);
@@ -2025,6 +2029,7 @@ static Compose *compose_forward_multiple(PrefsAccount *account, GSList *msginfo_
 			else
 				gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
 			quote_fmt_reset_vartable();
+			quote_fmtlex_destroy();
 
 			g_free(tmp);
 		}
@@ -3125,6 +3130,10 @@ static gchar *compose_quote_fmt(Compose *compose, MsgInfo *msginfo,
 		quote_fmt_parse();
 
 		buf = quote_fmt_get_buffer();
+
+		quote_fmt_reset_vartable();
+		quote_fmtlex_destroy();
+
 		if (buf == NULL)
 			alertpanel_error(_("The \"Quotation mark\" of the template is invalid."));
 		else
@@ -3158,11 +3167,18 @@ static gchar *compose_quote_fmt(Compose *compose, MsgInfo *msginfo,
 		}
 
 		buf = quote_fmt_get_buffer();
+
 		if (buf == NULL) {
 			gint line = quote_fmt_get_line();
 			alertpanel_error(err_msg, line);
+			quote_fmt_reset_vartable();
+			quote_fmtlex_destroy();
+
 			goto error;
 		}
+		quote_fmt_reset_vartable();
+		quote_fmtlex_destroy();
+
 	} else
 		buf = "";
 
@@ -8882,6 +8898,9 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
 		} else {
 			gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
 		}
+
+		quote_fmt_reset_vartable();
+		quote_fmtlex_destroy();
 	}
 
 	if (tmpl->to && *tmpl->to != '\0') {
@@ -8900,6 +8919,9 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
 		} else {
 			compose_entry_append(compose, buf, COMPOSE_TO, PREF_TEMPLATE);
 		}
+
+		quote_fmt_reset_vartable();
+		quote_fmtlex_destroy();
 	}
 
 	if (tmpl->cc && *tmpl->cc != '\0') {
@@ -8918,6 +8940,9 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
 		} else {
 			compose_entry_append(compose, buf, COMPOSE_CC, PREF_TEMPLATE);
 		}
+
+		quote_fmt_reset_vartable();
+		quote_fmtlex_destroy();
 	}
 
 	if (tmpl->bcc && *tmpl->bcc != '\0') {
@@ -8936,6 +8961,9 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
 		} else {
 			compose_entry_append(compose, buf, COMPOSE_BCC, PREF_TEMPLATE);
 		}
+
+		quote_fmt_reset_vartable();
+		quote_fmtlex_destroy();
 	}
 
 	if (tmpl->replyto && *tmpl->replyto != '\0') {
@@ -8954,6 +8982,9 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
 		} else {
 			compose_entry_append(compose, buf, COMPOSE_REPLYTO, PREF_TEMPLATE);
 		}
+
+		quote_fmt_reset_vartable();
+		quote_fmtlex_destroy();
 	}
 
 	/* process the subject */
@@ -8973,6 +9004,9 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
 		} else {
 			gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), buf);
 		}
+
+		quote_fmt_reset_vartable();
+		quote_fmtlex_destroy();
 	}
 
 	procmsg_msginfo_free( &dummyinfo );
diff --git a/src/prefs_template.c b/src/prefs_template.c
index 9e2f28e..e8f656d 100644
--- a/src/prefs_template.c
+++ b/src/prefs_template.c
@@ -714,9 +714,11 @@ gboolean prefs_template_string_is_valid(gchar *string, gint *line, gboolean esca
 		if (!parsed_buf) {
 			if (line)
 				*line = quote_fmt_get_line();
+			quote_fmtlex_destroy();
 			return FALSE;
 		}
 		quote_fmt_reset_vartable();
+		quote_fmtlex_destroy();
 	}
 	return result;
 }
diff --git a/src/quote_fmt.h b/src/quote_fmt.h
index b0112c5..900adea 100644
--- a/src/quote_fmt.h
+++ b/src/quote_fmt.h
@@ -45,6 +45,7 @@ void quote_fmt_init(MsgInfo *info, const gchar *my_quote_str,
 			gboolean escaped_string);
 #endif
 gint quote_fmtparse(void);
+int quote_fmtlex_destroy(void);
 void quote_fmt_scan_string(const gchar *str);
 void quote_fmt_reset_vartable(void);
 gint quote_fmt_get_cursor_pos(void);

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list