changeset 25649:c8606917787a

Avoid assertion failures on NULL 'from' attributes
author Paul Aurich <paul@darkrain42.org>
date Sun, 08 Feb 2009 06:40:15 +0000
parents 050052891c55
children d7c195489af3
files libpurple/protocols/jabber/iq.c libpurple/protocols/jabber/oob.c libpurple/protocols/jabber/ping.c
diffstat 3 files changed, 19 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/iq.c	Sun Feb 08 06:31:18 2009 +0000
+++ b/libpurple/protocols/jabber/iq.c	Sun Feb 08 06:40:15 2009 +0000
@@ -183,7 +183,8 @@
 	if(type == JABBER_IQ_GET) {
 		iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, "jabber:iq:last");
 		jabber_iq_set_id(iq, id);
-		xmlnode_set_attrib(iq->node, "to", from);
+		if (from)
+			xmlnode_set_attrib(iq->node, "to", from);
 
 		query = xmlnode_get_child(iq->node, "query");
 
@@ -215,7 +216,8 @@
 
 		iq = jabber_iq_new(js, JABBER_IQ_RESULT);
 		jabber_iq_set_id(iq, id);
-		xmlnode_set_attrib(iq->node, "to", from);
+		if (from)
+			xmlnode_set_attrib(iq->node, "to", from);
 
 		child = xmlnode_new_child(iq->node, child->name);
 		xmlnode_set_namespace(child, xmlns);
@@ -264,7 +266,8 @@
 #endif
 
 		iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, "jabber:iq:version");
-		xmlnode_set_attrib(iq->node, "to", from);
+		if (from)
+			xmlnode_set_attrib(iq->node, "to", from);
 		jabber_iq_set_id(iq, id);
 
 		query = xmlnode_get_child(iq->node, "query");
@@ -351,8 +354,11 @@
 
 			xmlnode_free(iq->node);
 			iq->node = xmlnode_copy(packet);
-			xmlnode_set_attrib(iq->node, "to", from);
-			xmlnode_remove_attrib(iq->node, "from");
+			if (from) {
+				xmlnode_set_attrib(iq->node, "to", from);
+				xmlnode_remove_attrib(iq->node, "from");
+			}
+
 			xmlnode_set_attrib(iq->node, "type", "error");
 			/* This id is clearly not useful, but we must put something there for a valid stanza */
 			iq->id = jabber_get_next_id(js);
@@ -399,8 +405,11 @@
 
 		xmlnode_free(iq->node);
 		iq->node = xmlnode_copy(packet);
-		xmlnode_set_attrib(iq->node, "to", from);
-		xmlnode_remove_attrib(iq->node, "from");
+		if (from) {
+			xmlnode_set_attrib(iq->node, "to", from);
+			xmlnode_remove_attrib(iq->node, "from");
+		}
+
 		xmlnode_set_attrib(iq->node, "type", "error");
 		error = xmlnode_new_child(iq->node, "error");
 		xmlnode_set_attrib(error, "type", "cancel");
--- a/libpurple/protocols/jabber/oob.c	Sun Feb 08 06:31:18 2009 +0000
+++ b/libpurple/protocols/jabber/oob.c	Sun Feb 08 06:40:15 2009 +0000
@@ -198,7 +198,7 @@
 	if(type != JABBER_IQ_SET)
 		return;
 
-	if(!querynode)
+	if(!from)
 		return;
 
 	if(!(urlnode = xmlnode_get_child(querynode, "url")))
--- a/libpurple/protocols/jabber/ping.c	Sun Feb 08 06:31:18 2009 +0000
+++ b/libpurple/protocols/jabber/ping.c	Sun Feb 08 06:40:15 2009 +0000
@@ -43,7 +43,8 @@
 	if (type == JABBER_IQ_GET) {
 		JabberIq *iq = jabber_iq_new(js, JABBER_IQ_RESULT);
 
-		xmlnode_set_attrib(iq->node, "to", from);
+		if (from)
+			xmlnode_set_attrib(iq->node, "to", from);
 		xmlnode_set_attrib(iq->node, "id", id);
 
 		jabber_iq_send(iq);