[evolution/webkit: 53/182] Fix crash when removing headers from emf->header_list



commit 244cc5d5b02869351cfb53d128752cf5c6b939c4
Author: Dan VrÃtil <dvratil redhat com>
Date:   Thu Nov 24 10:43:05 2011 +0100

    Fix crash when removing headers from emf->header_list

 em-format/em-format.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/em-format/em-format.c b/em-format/em-format.c
index a2a6931..27593f4 100644
--- a/em-format/em-format.c
+++ b/em-format/em-format.c
@@ -1712,18 +1712,29 @@ em_format_remove_header (EMFormat* emf,
 	g_return_val_if_fail (EM_IS_FORMAT (emf), NULL);
 	g_return_val_if_fail (name && *name, NULL);
 
-	for (iter = g_queue_peek_head_link (&emf->header_list); iter->next != NULL; iter = iter->next) {
-
+        iter = g_queue_peek_head_link (&emf->header_list);
+        while (iter) {
 		EMFormatHeader *header = iter->data;
 
+                if (!header->value || !*header->value) {
+                        GList *next = iter->next;
+                        if (g_strcmp0 (name, header->name) == 0)
+                                g_queue_delete_link (&emf->header_list, iter);
+
+                        iter = next;
+                        continue;
+                }
+
 		if (value && *value) {
-			if ((strcmp (name, header->name) == 0) &&
-			    (strcmp (value, header->value) == 0))
+			if ((g_strcmp0 (name, header->name) == 0) &&
+			    (g_strcmp0 (value, header->value) == 0))
 				break;
 		} else {
-			if (strcmp (name, header->name) == 0)
+			if (g_strcmp0 (name, header->name) == 0)
 				break;
 		}
+
+		iter = iter->next;
 	}
 
 	if (iter) {



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