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



commit 65e96a0902f0e567870878b685ed27d9ed0961de
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 a0438eb..d5336e1 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 d4e27cb..5f43f56 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -126,7 +126,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 35ed1cf..d20aa1b 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -377,6 +377,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]