[Commits] xml-plugin.c 1.9 1.10

miras at claws-mail.org miras at claws-mail.org
Sat Dec 17 16:50:44 CET 2011


Update of /home/claws-mail/contacts/plugins/xml
In directory claws-mail:/tmp/cvs-serv25519/plugins/xml

Modified Files:
	xml-plugin.c 
Log Message:
2011-12-17 [mir]	0.6.0cvs51

	* plugins/xml/xml-plugin.c
	    Fix memory leak and NULL pointer dereferencing

Index: xml-plugin.c
===================================================================
RCS file: /home/claws-mail/contacts/plugins/xml/xml-plugin.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- xml-plugin.c	28 Nov 2011 21:45:27 -0000	1.9
+++ xml-plugin.c	17 Dec 2011 15:50:41 -0000	1.10
@@ -271,9 +271,16 @@
 			break;
 	}
 	g_free(value);
-	k = g_markup_escape_text(key, -1);
-	v = g_markup_escape_text(tmp, -1);
-	g_free(tmp);
+	if (key)
+		k = g_markup_escape_text(key, -1);
+	else
+		k = g_strdup("");
+	if (tmp) {
+		v = g_markup_escape_text(tmp, -1);
+		g_free(tmp);
+	}
+	else
+		v = g_strdup("");
 	if (*str) {
 		tmp = g_strdup(*str);
 		g_free(*str);
@@ -284,6 +291,8 @@
 	else
 		*str = g_strconcat("<attribute name=\"", k, "\">", v,
 				"</attribute>", NULL);
+	g_free(k);
+	g_free(v);
 }
 
 static gchar* serialize(GHashTable* hash, GSList* emails) {
@@ -305,9 +314,18 @@
 	gslist_free(&attr, attrib_def_free);
 	for (mail = emails; mail; mail = g_slist_next(mail)) {
 		Email* email = (Email *) mail->data;
-		alias = g_markup_escape_text(email->alias, -1);
-		addr = g_markup_escape_text(email->email, -1);
-		remarks = g_markup_escape_text(email->remarks, -1);
+		if (email->alias)
+			alias = g_markup_escape_text(email->alias, -1);
+		else
+			alias = g_strdup("");
+		if (email->email)
+			addr = g_markup_escape_text(email->email, -1);
+		else
+			addr = g_strdup("");
+		if (email->remarks)
+			remarks = g_markup_escape_text(email->remarks, -1);
+		else
+			remarks = g_strdup("");
 		debug_print("Email address: alias: %s email: %s remarks: %s\n",
 			alias, addr, remarks);
 		if (mails) {



More information about the Commits mailing list