[evolution] Fix a memory leak when replying to a message



commit b0eca85eb4d12fef1f5857c280ba13fb925c0bfc
Author: Milan Crha <mcrha redhat com>
Date:   Wed Sep 12 13:53:56 2012 +0200

    Fix a memory leak when replying to a message

 mail/e-mail-reader-utils.c |    3 +++
 mail/em-utils.c            |    8 +++++++-
 2 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index 6f0a982..4ce1afb 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -1271,6 +1271,7 @@ mail_reader_reply_message_parsed (GObject *object,
 		context->reply_type, context->reply_style,
 		part_list, context->address);
 
+	g_object_unref (part_list);
 	async_context_free (context);
 }
 
@@ -1396,10 +1397,12 @@ e_mail_reader_reply_to_message (EMailReader *reader,
 			g_object_ref (src_message);
 
 		g_object_unref (part_list);
+		part_list = NULL;
 
 		g_return_if_fail (src_message != NULL);
 	} else {
 		g_object_unref (part_list);
+		part_list = NULL;
 	}
 
 	if (!e_web_view_is_selection_active (web_view))
diff --git a/mail/em-utils.c b/mail/em-utils.c
index a5e8c05..f7f12e5 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -1290,7 +1290,7 @@ em_utils_message_to_html (CamelSession *session,
                           guint32 *validity_found)
 {
 	EMailFormatter *formatter;
-	EMailParser *parser;
+	EMailParser *parser = NULL;
 	CamelStream *mem;
 	GByteArray *buf;
 	EShell *shell;
@@ -1328,6 +1328,8 @@ em_utils_message_to_html (CamelSession *session,
 
 		parser = e_mail_parser_new (session);
 		parts_list = e_mail_parser_parse_sync (parser, NULL, NULL, message, NULL);
+	} else {
+		g_object_ref (parts_list);
 	}
 
 	/* Return all found validities and possibly show hidden prefer-plain part */
@@ -1362,6 +1364,10 @@ em_utils_message_to_html (CamelSession *session,
 	if (hidden_text_html_part)
 		hidden_text_html_part->is_hidden = TRUE;
 
+	g_object_unref (parts_list);
+	if (parser)
+		g_object_unref (parser);
+
 	if (append && *append)
 		camel_stream_write_string (mem, append, NULL, NULL);
 



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