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



commit 45e3ca1fb4ce8b3e8bee3caf2af2a32a92770c19
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 |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/em-format/em-format.c b/em-format/em-format.c
index 0765165..407ba2e 100644
--- a/em-format/em-format.c
+++ b/em-format/em-format.c
@@ -34,11 +34,12 @@
 #include "shell/e-shell.h"
 #include "shell/e-shell-settings.h"
 
+#define d(x) x
+
 #define EM_FORMAT_GET_PRIVATE(obj) \
 	(G_TYPE_INSTANCE_GET_PRIVATE \
 	((obj), EM_TYPE_FORMAT, EMFormatPrivate))
 
-#define d(x)
 
 struct _EMFormatPrivate {
 	GNode *current_node;
@@ -1392,6 +1393,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);
 }
@@ -1926,18 +1929,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]