[evolution/webkit] Fix memory leak and prevent some crashes



commit 9df5f43dfdcba61a0ef9da9a8000d2bb6347a41a
Author: Dan VrÃtil <dvratil redhat com>
Date:   Thu Dec 1 17:29:00 2011 +0100

    Fix memory leak and prevent some crashes
    
    - clear all headers in EMFormat->headers_list
    - verify that handler->parse_func is not null before calling it

 em-format/em-format.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/em-format/em-format.c b/em-format/em-format.c
index 416c835..2f1303d 100644
--- a/em-format/em-format.c
+++ b/em-format/em-format.c
@@ -34,7 +34,7 @@
 #include "shell/e-shell.h"
 #include "shell/e-shell-settings.h"
 
-#define d(x)
+#define d(x) x
 
 struct _EMFormatPrivate {
 	GNode *current_node;
@@ -1388,6 +1388,8 @@ em_format_finalize (GObject *object)
 		emf->priv->charset = NULL;
 	}
 
+        em_format_clear_headers (emf);
+
 	/* Chain up to parent's finalize() method */
 	G_OBJECT_CLASS (parent_class)->finalize (object);
 }
@@ -1922,18 +1924,24 @@ em_format_parse_part_as (EMFormat *emf,
                 ninfo.is_attachment = TRUE;
                 handler = em_format_find_handler (emf, "x-evolution/message/attachment");
                 ninfo.handler = handler;
-                handler->parse_func (emf, part, part_id, &ninfo, cancellable);
+
+                if (handler && handler->parse_func)
+                        handler->parse_func (emf, part, part_id, &ninfo, cancellable);
+
                 return;
         }
 
 	handler = em_format_find_handler (emf, mime_type);
-	if (handler) {
+	if (handler && handler->parse_func) {
 		ninfo.handler = handler;
 		handler->parse_func (emf, part, part_id, &ninfo, cancellable);
 	} else {
 		handler = em_format_find_handler (emf, "x-evolution/message/attachment");
 		ninfo.handler = handler;
-		handler->parse_func (emf, part, part_id, &ninfo, cancellable);
+
+                /* When this fails, something is probably very wrong...*/
+                if (handler && handler->parse_func)
+		        handler->parse_func (emf, part, part_id, &ninfo, cancellable);
 	}
 }
 



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