From 79b860a6c21124e3113af1055d0d0cfd50319c90 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Tue, 2 Nov 2004 02:33:34 +0000 Subject: ** See bug #68787 2004-11-01 Not Zed ** See bug #68787 * e-account.c (xml_set_content): check the new val isn't null before dereferencing it. * e-account.c (xml_set_prop): same here. svn path=/trunk/; revision=27789 --- e-util/e-account.c | 69 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 30 deletions(-) (limited to 'e-util/e-account.c') diff --git a/e-util/e-account.c b/e-util/e-account.c index 61282ced8e..c75c0cf7f8 100644 --- a/e-util/e-account.c +++ b/e-util/e-account.c @@ -245,45 +245,51 @@ xml_set_int (xmlNodePtr node, const char *name, int *val) static gboolean xml_set_prop (xmlNodePtr node, const char *name, char **val) { - char *buf, *new_val; - - buf = xmlGetProp (node, name); - new_val = g_strdup (buf); - xmlFree (buf); - - /* We can use strcmp here whether the value is UTF8 or - * not, since we only care if the bytes changed. - */ - if (!*val || strcmp (*val, new_val)) { - g_free (*val); - *val = new_val; - return TRUE; + char *buf; + int res; + + buf = xmlGetProp(node, name); + if (buf == NULL) { + res = (*val != NULL); + if (res) { + g_free(*val); + *val = NULL; + } } else { - g_free (new_val); - return FALSE; + res = *val == NULL || strcmp(*val, buf) != 0; + if (res) { + g_free(*val); + *val = g_strdup(buf); + } + xmlFree(buf); } + + return res; } static gboolean xml_set_content (xmlNodePtr node, char **val) { - char *buf, *new_val; - - buf = xmlNodeGetContent (node); - new_val = g_strdup (buf); - xmlFree (buf); - - /* We can use strcmp here whether the value is UTF8 or - * not, since we only care if the bytes changed. - */ - if (!*val || strcmp (*val, new_val)) { - g_free (*val); - *val = new_val; - return TRUE; + char *buf; + int res; + + buf = xmlNodeGetContent(node); + if (buf == NULL) { + res = (*val != NULL); + if (res) { + g_free(*val); + *val = NULL; + } } else { - g_free (new_val); - return FALSE; + res = *val == NULL || strcmp(*val, buf) != 0; + if (res) { + g_free(*val); + *val = g_strdup(buf); + } + xmlFree(buf); } + + return res; } static gboolean @@ -303,6 +309,9 @@ xml_set_identity (xmlNodePtr node, EAccountIdentity *id) else if (!strcmp (node->name, "signature")) { changed |= xml_set_prop (node, "uid", &id->sig_uid); if (!id->sig_uid) { + + /* WTF is this shit doing here? Migrate is supposed to "handle this" */ + /* set a fake sig uid so the migrate code can handle this */ gboolean autogen = FALSE; int sig_id = 0; -- cgit v1.2.3