# HG changeset patch # User Paul Aurich # Date 1234075215 0 # Node ID c8606917787a134fd02dff0a998f966c4c45146e # Parent 050052891c559bdb70088ab5364aa2d4801e297c Avoid assertion failures on NULL 'from' attributes diff -r 050052891c55 -r c8606917787a libpurple/protocols/jabber/iq.c --- 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"); diff -r 050052891c55 -r c8606917787a libpurple/protocols/jabber/oob.c --- 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"))) diff -r 050052891c55 -r c8606917787a libpurple/protocols/jabber/ping.c --- 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);