# HG changeset patch # User Tim Ringenbach # Date 1084941796 0 # Node ID 8e69a730885cabfde6a1599dfbfc3587153506a3 # Parent 52fba1dafe0eff1025f4d29c49a8a09f713bceb4 [gaim-migrate @ 9752] This fixes a bug whereby an oscar_direct_im could get destroyed, and then gaim_proxy_connect would call its callback and we'd try to dereference it. Als some small whitespace changes that my editor made for me. committer: Tailor Script diff -r 52fba1dafe0e -r 8e69a730885c src/protocols/oscar/aim.h --- a/src/protocols/oscar/aim.h Wed May 19 04:41:01 2004 +0000 +++ b/src/protocols/oscar/aim.h Wed May 19 04:43:16 2004 +0000 @@ -1,4 +1,4 @@ -/* +/* * Main libfaim header. Must be included in client for prototypes/macros. * * "come on, i turned a chick lesbian; i think this is the hackish equivalent" diff -r 52fba1dafe0e -r 8e69a730885c src/protocols/oscar/im.c --- a/src/protocols/oscar/im.c Wed May 19 04:41:01 2004 +0000 +++ b/src/protocols/oscar/im.c Wed May 19 04:43:16 2004 +0000 @@ -486,7 +486,7 @@ hdrlen = 2+8+16+6+4+4+strlen(msg)+4+2+1+strlen(roomname)+2; hdr = malloc(hdrlen); aim_bstream_init(&hdrbs, hdr, hdrlen); - + aimbs_put16(&hdrbs, 0x0000); /* Unknown! */ aimbs_putraw(&hdrbs, ck, sizeof(ck)); /* I think... */ aim_putcap(&hdrbs, AIM_CAPS_CHAT); @@ -592,7 +592,7 @@ * * You'd think this would be in icq.c, but, well, I'm trying to stick with * the one-group-per-file scheme as much as possible. This could easily - * be an exception, since Rendezvous IMs are external of the Oscar core, + * be an exception, since Rendezvous IMs are external of the Oscar core, * and therefore are undefined. Really I just need to think of a good way to * make an interface similar to what AOL actually uses. But I'm not using COM. * @@ -700,10 +700,10 @@ snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, NULL, 0); aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid); - /* - * Generate a random message cookie + /* + * Generate a random message cookie * - * This cookie needs to be alphanumeric and NULL-terminated to be + * This cookie needs to be alphanumeric and NULL-terminated to be * TOC-compatible. * * XXX - have I mentioned these should be generated in msgcookie.c? @@ -1736,7 +1736,7 @@ memset(&args, 0, sizeof(args)); /* - * There's another block of TLVs embedded in the type 5 here. + * There's another block of TLVs embedded in the type 5 here. */ block1 = aim_tlv_gettlv(tlvlist, 0x0005, 1); aim_bstream_init(&bbs, block1->value, block1->length); @@ -1745,14 +1745,14 @@ * First two bytes represent the status of the connection. * * 0 is a request, 1 is a cancel, 2 is an accept - */ + */ args.status = aimbs_get16(&bbs); /* * Next comes the cookie. Should match the ICBM cookie. */ cookie2 = aimbs_getraw(&bbs, 8); - if (memcmp(cookie, cookie2, 8) != 0) + if (memcmp(cookie, cookie2, 8) != 0) faimdprintf(sess, 0, "rend: warning cookies don't match!\n"); memcpy(args.cookie, cookie2, 8); free(cookie2); diff -r 52fba1dafe0e -r 8e69a730885c src/protocols/oscar/oscar.c --- a/src/protocols/oscar/oscar.c Wed May 19 04:41:01 2004 +0000 +++ b/src/protocols/oscar/oscar.c Wed May 19 04:43:16 2004 +0000 @@ -141,6 +141,8 @@ int watcher; aim_conn_t *conn; gboolean connected; + gboolean gpc_pend; + gboolean killme; }; struct ask_direct { @@ -708,6 +710,10 @@ "destroying Direct IM for %s.\n", dim->name); od->direct_ims = g_slist_remove(od->direct_ims, dim); + if (dim->gpc_pend) { + dim->killme = TRUE; + return; + } if (dim->watcher) gaim_input_remove(dim->watcher); if (dim->conn) { @@ -728,7 +734,7 @@ if (dim->connected) g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); - else + else g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); conv = gaim_find_conversation_with_account(dim->name, gaim_connection_get_account(dim->gc)); @@ -777,6 +783,12 @@ g_return_if_fail(gc != NULL); + dim->gpc_pend = FALSE; + if (dim->killme) { + oscar_direct_im_destroy(od, dim); + return; + } + if (!g_list_find(gaim_connections_get_all(), gc)) { oscar_direct_im_destroy(od, dim); return; @@ -850,9 +862,11 @@ } host = g_strndup(d->ip, i); dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; + dim->gpc_pend = TRUE; rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); g_free(host); if (rc < 0) { + dim->gpc_pend = FALSE; oscar_direct_im_disconnect(od, dim); destroy_direct_im_request(d); return;