[evolution/webkit: 49/57] Fix memory leaks in formatter



commit c1610642b16530798f55386e63867e740553bff7
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 c267003..0b8f6e0 100644
--- a/em-format/em-format.c
+++ b/em-format/em-format.c
@@ -217,7 +217,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;
 
@@ -230,6 +230,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);
@@ -518,6 +520,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 */
@@ -637,7 +641,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;
@@ -656,6 +660,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);
 		}
 	}
 
@@ -882,7 +888,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);
 
@@ -893,6 +899,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);
@@ -960,10 +967,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);
 
@@ -974,6 +981,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 0c47eac..f48e5b6 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -122,7 +122,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 a66d3a3..bc2ae9a 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -373,6 +373,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]