[evolution/webkit: 32/182] Fix memory leaks in formatter



commit aef566c70bf91e358694efae3ad86e84553f2c0c
Author: Dan VrÃtil <dvratil redhat com>
Date:   Thu Sep 22 14:00:12 2011 +0200

    Fix memory leaks in formatter

 em-format/em-format.c         |   18 +++++++++++++-----
 mail/e-mail-request.c         |    4 +++-
 mail/em-format-html-display.c |    3 ++-
 mail/em-format-html.c         |    3 +++
 4 files changed, 21 insertions(+), 7 deletions(-)
---
diff --git a/em-format/em-format.c b/em-format/em-format.c
index e20097f..baa5daf 100644
--- a/em-format/em-format.c
+++ b/em-format/em-format.c
@@ -221,7 +221,7 @@ emf_parse_application_xpkcs7mime (EMFormat *emf,
 		EMFormatParserInfo encinfo = {
 				info->handler,
 				EM_FORMAT_VALIDITY_FOUND_ENCRYPTED | EM_FORMAT_VALIDITY_FOUND_SMIME,
-				camel_cipher_validity_clone (valid),
+				valid
 		};
 		gint len = part_id->len;
 
@@ -234,6 +234,8 @@ emf_parse_application_xpkcs7mime (EMFormat *emf,
 		em_format_parse_part_as (emf, part, part_id, &encinfo,
 			"x-evolution/message/x-secure-button", cancellable);
 		g_string_truncate (part_id, len);
+
+		camel_cipher_validity_free (valid);
 	}
 
 	g_object_unref (opart);
@@ -522,6 +524,8 @@ emf_parse_multipart_encrypted (EMFormat *emf,
 		em_format_parse_part_as (emf, part, part_id, &encinfo,
 			"x-evolution/message/x-secure-button", cancellable);
 		g_string_truncate (part_id, len);
+
+		camel_cipher_validity_free (valid);
 	}
 
 	/* TODO: Make sure when we finalize this part, it is zero'd out */
@@ -641,7 +645,7 @@ emf_parse_multipart_signed (EMFormat *emf,
 			EMFormatParserInfo signinfo = {
 					info->handler,
 					validity_type | EM_FORMAT_VALIDITY_FOUND_SIGNED,
-					camel_cipher_validity_clone (valid)
+					valid
 			};
 
 			gint i, nparts, len = part_id->len;
@@ -660,6 +664,8 @@ emf_parse_multipart_signed (EMFormat *emf,
 			em_format_parse_part_as (emf, part, part_id, &signinfo,
 			"x-evolution/message/x-secure-button", cancellable);
 			g_string_truncate (part_id, len);
+
+			camel_cipher_validity_free (valid);
 		}
 	}
 
@@ -886,7 +892,7 @@ emf_parse_inlinepgp_signed (EMFormat *emf,
 	g_string_append (part_id, ".inlinepgp_signed");
 	signinfo.handler = info->handler;
 	signinfo.validity_type = EM_FORMAT_VALIDITY_FOUND_SIGNED | EM_FORMAT_VALIDITY_FOUND_PGP;
-	signinfo.validity = camel_cipher_validity_clone (valid);
+	signinfo.validity = valid;
 	em_format_parse_part (emf, opart, part_id, &signinfo, cancellable);
 	g_string_truncate (part_id, len);
 
@@ -897,6 +903,7 @@ emf_parse_inlinepgp_signed (EMFormat *emf,
 	g_string_truncate (part_id, len);
 
 	/* Clean Up */
+	camel_cipher_validity_free (valid);
 	g_object_unref (dw);
 	g_object_unref (opart);
 	g_object_unref (ostream);
@@ -964,10 +971,10 @@ emf_parse_inlinepgp_encrypted (EMFormat *emf,
 
 	/* Pass it off to the real formatter */
 	len = part_id->len;
-	g_string_append (part_id, ".inlinegpg_encrypted");
+	g_string_append (part_id, ".inlinepgp_encrypted");
 	encinfo.handler = info->handler;
 	encinfo.validity_type = EM_FORMAT_VALIDITY_FOUND_ENCRYPTED | EM_FORMAT_VALIDITY_FOUND_PGP;
-	encinfo.validity = camel_cipher_validity_clone (valid);
+	encinfo.validity = valid;
 	em_format_parse_part (emf, opart, part_id, &encinfo, cancellable);
 	g_string_truncate (part_id, len);
 
@@ -978,6 +985,7 @@ emf_parse_inlinepgp_encrypted (EMFormat *emf,
 	g_string_truncate (part_id, len);
 
 	/* Clean Up */
+	camel_cipher_validity_free (valid);
 	g_object_unref (opart);
 	g_object_unref (cipher);
 }
diff --git a/mail/e-mail-request.c b/mail/e-mail-request.c
index cf40415..1f5151e 100644
--- a/mail/e-mail-request.c
+++ b/mail/e-mail-request.c
@@ -7,7 +7,7 @@
 
 #include "em-format-html.h"
 
-#define d(x) x
+#define d(x)
 
 G_DEFINE_TYPE (EMailRequest, e_mail_request, SOUP_TYPE_REQUEST)
 
@@ -90,6 +90,8 @@ get_file_content (GSimpleAsyncResult *res,
 
 		stream = g_memory_input_stream_new_from_data (contents, length, NULL);
 		g_simple_async_result_set_op_res_gpointer (res, stream, NULL);
+
+		g_free (contents);
 	}
 }
 
diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c
index 9cfb4fc..bfffa0a 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -130,7 +130,8 @@ efhd_xpkcs7mime_free (EMFormatPURI *puri)
 	if (sp->description)
 		g_free (sp->description);
 
-	camel_cipher_validity_free (sp->valid);
+	if (sp->valid)
+		camel_cipher_validity_free (sp->valid);
 }
 
 static void
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index 1f03241..74b01eb 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -380,6 +380,9 @@ efh_parse_text_html (EMFormat *emf,
 
 	em_format_add_puri (emf, puri);
 	g_string_truncate (part_id, len);
+
+	if (cid)
+		g_free (cid);
 }
 
 static void



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