Patch: fix for camel_header_set_param



	Hi,

	This patch should avoid crashes when camel_header_set_param was applied
to a non empty param list. The problem is a trivial logic error (we were
accessing a ** as a * :).

Changelog entry would be:
* libtinymail-camel/camel-lite/camel/camel-mime-utils.c: fix
  camel_header_set_param as it could cause crashes on setting params
  if a param struct was already available.

-- 
José Dapena Paz <jdapena igalia com>
Igalia
diff --git a/ChangeLog b/ChangeLog
index e100993..363e464 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-02-16  Jose Dapena Paz  <jdapena igalia com>
+
+	* libtinymail-camel/camel-lite/camel/camel-mime-utils.c: fix
+	camel_header_set_param as it could cause crashes on setting params
+	if a param struct was already available.
+
 2009-02-09  Jose Dapena Paz  <jdapena igalia com>
 
 	* libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c:
diff --git a/libtinymail-camel/camel-lite/camel/camel-mime-utils.c b/libtinymail-camel/camel-lite/camel/camel-mime-utils.c
index 84c4de4..93cc111 100644
--- a/libtinymail-camel/camel-lite/camel/camel-mime-utils.c
+++ b/libtinymail-camel/camel-lite/camel/camel-mime-utils.c
@@ -2162,12 +2162,12 @@ camel_header_param (struct _camel_header_param *p, const char *name)
 struct _camel_header_param *
 camel_header_set_param (struct _camel_header_param **l, const char *name, const char *value)
 {
-	struct _camel_header_param *p = (struct _camel_header_param *)l, *pn;
+	struct _camel_header_param *p = (struct _camel_header_param *) *l, *pn;
 
 	if (name == NULL)
 		return NULL;
 
-	while (p->next) {
+	while (p && p->next) {
 		pn = p->next;
 		if (!g_ascii_strcasecmp (pn->name, name)) {
 			g_free (pn->value);
@@ -2191,7 +2191,12 @@ camel_header_set_param (struct _camel_header_param **l, const char *name, const
 	pn->next = 0;
 	pn->name = g_strdup (name);
 	pn->value = g_strdup (value);
-	p->next = pn;
+
+	if (p) {
+		p->next = pn;
+	} else {
+		*l = pn;
+	}
 
 	return pn;
 }


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