Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/bosh.c @ 25790:4e624cc0c4a5
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)
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sun, 18 Jan 2009 04:13:39 +0000 |
parents | b78c8ab5de2b |
children | 26259ee81c5b |
comparison
equal
deleted
inserted
replaced
25789:b78c8ab5de2b | 25790:4e624cc0c4a5 |
---|---|
276 if (jabber_bosh_connection_error_check(conn, node)) | 276 if (jabber_bosh_connection_error_check(conn, node)) |
277 return; | 277 return; |
278 | 278 |
279 child = node->child; | 279 child = node->child; |
280 while (child != NULL) { | 280 while (child != NULL) { |
281 /* jabber_process_packet might free child */ | |
282 xmlnode *next = child->next; | |
281 if (child->type == XMLNODE_TYPE_TAG) { | 283 if (child->type == XMLNODE_TYPE_TAG) { |
282 xmlnode *session = NULL; | 284 if (!strcmp(child->name, "iq")) { |
283 if (!strcmp(child->name, "iq")) session = xmlnode_get_child(child, "session"); | 285 if (xmlnode_get_child(child, "session")) |
284 if (session) { | 286 conn->ready = TRUE; |
285 conn->ready = TRUE; | |
286 } | 287 } |
288 | |
287 jabber_process_packet(js, &child); | 289 jabber_process_packet(js, &child); |
288 } | 290 } |
289 child = child->next; | 291 |
292 child = next; | |
290 } | 293 } |
291 } | 294 } |
292 | 295 |
293 static void auth_response_cb(PurpleBOSHConnection *conn, xmlnode *node) { | 296 static void auth_response_cb(PurpleBOSHConnection *conn, xmlnode *node) { |
294 xmlnode *child; | 297 xmlnode *child; |
295 | 298 |
296 g_return_if_fail(node == NULL); | 299 g_return_if_fail(node != NULL); |
297 if (jabber_bosh_connection_error_check(conn, node)) | 300 if (jabber_bosh_connection_error_check(conn, node)) |
298 return; | 301 return; |
299 | 302 |
300 child = node->child; | 303 child = node->child; |
301 while(child != NULL && child->type != XMLNODE_TYPE_TAG) { | 304 while(child != NULL && child->type != XMLNODE_TYPE_TAG) { |
412 xmlnode_set_attrib(packet, "xmlns", "http://jabber.org/protocol/httpbind"); | 415 xmlnode_set_attrib(packet, "xmlns", "http://jabber.org/protocol/httpbind"); |
413 xmlnode_set_attrib(packet, "sid", conn->sid); | 416 xmlnode_set_attrib(packet, "sid", conn->sid); |
414 xmlnode_set_attrib(packet, "rid", rid); | 417 xmlnode_set_attrib(packet, "rid", rid); |
415 | 418 |
416 if (node) { | 419 if (node) { |
417 xmlnode_insert_child(packet, node); | 420 xmlnode *copy = xmlnode_copy(node); |
418 if (conn->ready == TRUE) xmlnode_set_attrib(node, "xmlns", "jabber:client"); | 421 xmlnode_insert_child(packet, copy); |
422 if (conn->ready == TRUE) | |
423 xmlnode_set_attrib(copy, "xmlns", "jabber:client"); | |
419 } | 424 } |
420 jabber_bosh_connection_send_native(conn, packet); | 425 jabber_bosh_connection_send_native(conn, packet); |
421 xmlnode_free(packet); | 426 xmlnode_free(packet); |
422 } | 427 } |
423 | 428 |