cpw.darkrain42.xmpp.bosh: f3aa6c57: Jabber BOSH: memory management fixes
paul at darkrain42.org
paul at darkrain42.org
Sat Jan 17 23:57:03 EST 2009
-----------------------------------------------------------------
Revision: f3aa6c57ecb65ae9dbf729bca259e94f48b87279
Ancestor: 1bfe3441a9c9ca7e7a180babebca02b43b5c7d9b
Author: paul at darkrain42.org
Date: 2009-01-18T04:13:39
Branch: im.pidgin.cpw.darkrain42.xmpp.bosh
URL: http://d.pidgin.im/viewmtn/revision/info/f3aa6c57ecb65ae9dbf729bca259e94f48b87279
Modified files:
libpurple/protocols/jabber/bosh.c
ChangeLog:
Jabber BOSH: memory management fixes
* jabber_process_packet might free the packet.
* logic in a g_return_if_fail was backward
* copy the node when putting it into the BOSH node (double free)
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/bosh.c cedaec3592a331f72168379c505228b0232660ae
+++ libpurple/protocols/jabber/bosh.c 71c5f83d2b30729d95b70f71a34193fad4a9efd6
@@ -278,22 +278,25 @@ static void jabber_bosh_connection_recei
child = node->child;
while (child != NULL) {
+ /* jabber_process_packet might free child */
+ xmlnode *next = child->next;
if (child->type == XMLNODE_TYPE_TAG) {
- xmlnode *session = NULL;
- if (!strcmp(child->name, "iq")) session = xmlnode_get_child(child, "session");
- if (session) {
- conn->ready = TRUE;
+ if (!strcmp(child->name, "iq")) {
+ if (xmlnode_get_child(child, "session"))
+ conn->ready = TRUE;
}
+
jabber_process_packet(js, &child);
}
- child = child->next;
+
+ child = next;
}
}
static void auth_response_cb(PurpleBOSHConnection *conn, xmlnode *node) {
xmlnode *child;
- g_return_if_fail(node == NULL);
+ g_return_if_fail(node != NULL);
if (jabber_bosh_connection_error_check(conn, node))
return;
@@ -414,8 +417,10 @@ void jabber_bosh_connection_send(PurpleB
xmlnode_set_attrib(packet, "rid", rid);
if (node) {
- xmlnode_insert_child(packet, node);
- if (conn->ready == TRUE) xmlnode_set_attrib(node, "xmlns", "jabber:client");
+ xmlnode *copy = xmlnode_copy(node);
+ xmlnode_insert_child(packet, copy);
+ if (conn->ready == TRUE)
+ xmlnode_set_attrib(copy, "xmlns", "jabber:client");
}
jabber_bosh_connection_send_native(conn, packet);
xmlnode_free(packet);
More information about the Commits
mailing list