[evolution] Bug #598877 - Crash while sending mail, in report_status function



commit f2e75c5d13a0899b042e7c7f60639be19871f7ca
Author: Milan Crha <mcrha redhat com>
Date:   Thu Nov 5 21:01:18 2009 +0100

    Bug #598877 - Crash while sending mail, in report_status function

 mail/mail-ops.c       |   32 ++++++++++++++++++++++++++++++--
 mail/mail-send-recv.c |    6 ++++--
 2 files changed, 34 insertions(+), 4 deletions(-)
---
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 2de8f6d..8110ab4 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -429,6 +429,28 @@ mail_fetch_mail (const gchar *source, gint keep, const gchar *type, CamelOperati
 	mail_msg_unordered_push (m);
 }
 
+static gchar *
+escape_percent_sign (const gchar *str)
+{
+	GString *res;
+
+	if (!str)
+		return NULL;
+
+	res = g_string_sized_new (strlen (str));
+	while (*str) {
+		if (*str == '%') {
+			g_string_append (res, "%%");
+		} else {
+			g_string_append_c (res, *str);
+		}
+
+		str++;
+	}
+
+	return g_string_free (res, FALSE);
+}
+
 /* ********************************************************************** */
 /* sending stuff */
 /* ** SEND MAIL *********************************************************** */
@@ -502,8 +524,14 @@ mail_send_message (struct _send_queue_msg *m, CamelFolder *queue, const gchar *u
 			sent_folder_uri = g_strstrip(g_strdup(tmp));
 	}
 
-	/* let the dialog know the right account it is using; percentage is ignored */
-	report_status (m, CAMEL_FILTER_STATUS_ACTION, 0, transport_url ? transport_url : destination);
+	if (transport_url || destination) {
+		gchar *escaped = escape_percent_sign (transport_url ? transport_url : destination);
+
+		/* let the dialog know the right account it is using; percentage is ignored */
+		report_status (m, CAMEL_FILTER_STATUS_ACTION, 0, escaped);
+
+		g_free (escaped);
+	}
 
 	/* Check for email sending */
 	from = (CamelAddress *) camel_internet_address_new ();
diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c
index 6244685..1495f09 100644
--- a/mail/mail-send-recv.c
+++ b/mail/mail-send-recv.c
@@ -359,7 +359,7 @@ format_url (const gchar *internal_url, const gchar *account_name)
 		else
 			pretty_url = g_strdup_printf("<b>%s (%s)</b>", account_name, url->protocol);
 	}
-	else {
+	else if (url) {
 		if (url->host && *url->host)
 			pretty_url = g_strdup_printf("<b>%s</b>: %s", url->protocol, url->host);
 		else if (url->path)
@@ -367,7 +367,9 @@ format_url (const gchar *internal_url, const gchar *account_name)
 		else
 			pretty_url = g_strdup_printf("<b>%s</b>", url->protocol);
 	}
-	camel_url_free(url);
+
+	if (url)
+		camel_url_free(url);
 
         return pretty_url;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]