Mercurial > pidgin
changeset 15283:c2f15e2117dc
[gaim-migrate @ 18073]
gaim_xfer_new() can return NULL via g_return_if_fail(). It should therefore not be assumed that it returns a GaimXfer; check against its return value before proceeding when creating a GaimXfer.
committer: Tailor Script <tailor@pidgin.im>
author | Evan Schoenberg <evan.s@dreskin.net> |
---|---|
date | Thu, 04 Jan 2007 23:20:12 +0000 |
parents | 8e39ca9b954a |
children | e8f8749e6182 |
files | libgaim/protocols/irc/dcc_send.c libgaim/protocols/jabber/oob.c libgaim/protocols/jabber/si.c libgaim/protocols/msn/msn.c libgaim/protocols/msn/slp.c libgaim/protocols/oscar/oscar.c libgaim/protocols/oscar/peer.c libgaim/protocols/qq/send_file.c libgaim/protocols/sametime/sametime.c libgaim/protocols/yahoo/yahoo_filexfer.c |
diffstat | 10 files changed, 251 insertions(+), 211 deletions(-) [+] |
line wrap: on
line diff
--- a/libgaim/protocols/irc/dcc_send.c Thu Jan 04 19:21:10 2007 +0000 +++ b/libgaim/protocols/irc/dcc_send.c Thu Jan 04 23:20:12 2007 +0000 @@ -108,31 +108,34 @@ i++; xfer = gaim_xfer_new(irc->account, GAIM_XFER_RECEIVE, from); - xd = g_new0(struct irc_xfer_rx_data, 1); - xfer->data = xd; + if (xfer) + { + xd = g_new0(struct irc_xfer_rx_data, 1); + xfer->data = xd; - gaim_xfer_set_filename(xfer, filename->str); - xfer->remote_port = atoi(token[i+1]); + gaim_xfer_set_filename(xfer, filename->str); + xfer->remote_port = atoi(token[i+1]); - nip = strtoul(token[i], NULL, 10); - if (nip) { - addr.s_addr = htonl(nip); - xd->ip = g_strdup(inet_ntoa(addr)); - } else { - xd->ip = g_strdup(token[i]); + nip = strtoul(token[i], NULL, 10); + if (nip) { + addr.s_addr = htonl(nip); + xd->ip = g_strdup(inet_ntoa(addr)); + } else { + xd->ip = g_strdup(token[i]); + } + gaim_debug(GAIM_DEBUG_INFO, "irc", "Receiving file from %s\n", + xd->ip); + gaim_xfer_set_size(xfer, token[i+2] ? atoi(token[i+2]) : 0); + + gaim_xfer_set_init_fnc(xfer, irc_dccsend_recv_init); + gaim_xfer_set_ack_fnc(xfer, irc_dccsend_recv_ack); + + gaim_xfer_set_end_fnc(xfer, irc_dccsend_recv_destroy); + gaim_xfer_set_request_denied_fnc(xfer, irc_dccsend_recv_destroy); + gaim_xfer_set_cancel_send_fnc(xfer, irc_dccsend_recv_destroy); + + gaim_xfer_request(xfer); } - gaim_debug(GAIM_DEBUG_INFO, "irc", "Receiving file from %s\n", - xd->ip); - gaim_xfer_set_size(xfer, token[i+2] ? atoi(token[i+2]) : 0); - - gaim_xfer_set_init_fnc(xfer, irc_dccsend_recv_init); - gaim_xfer_set_ack_fnc(xfer, irc_dccsend_recv_ack); - - gaim_xfer_set_end_fnc(xfer, irc_dccsend_recv_destroy); - gaim_xfer_set_request_denied_fnc(xfer, irc_dccsend_recv_destroy); - gaim_xfer_set_cancel_send_fnc(xfer, irc_dccsend_recv_destroy); - - gaim_xfer_request(xfer); g_strfreev(token); g_string_free(filename, TRUE); } @@ -344,17 +347,19 @@ /* Build the file transfer handle */ xfer = gaim_xfer_new(gaim_connection_get_account(gc), GAIM_XFER_SEND, who); - - xd = g_new0(struct irc_xfer_send_data, 1); - xd->fd = -1; - xfer->data = xd; + if (xfer) + { + xd = g_new0(struct irc_xfer_send_data, 1); + xd->fd = -1; + xfer->data = xd; - /* Setup our I/O op functions */ - gaim_xfer_set_init_fnc(xfer, irc_dccsend_send_init); - gaim_xfer_set_write_fnc(xfer, irc_dccsend_send_write); - gaim_xfer_set_end_fnc(xfer, irc_dccsend_send_destroy); - gaim_xfer_set_request_denied_fnc(xfer, irc_dccsend_send_destroy); - gaim_xfer_set_cancel_send_fnc(xfer, irc_dccsend_send_destroy); + /* Setup our I/O op functions */ + gaim_xfer_set_init_fnc(xfer, irc_dccsend_send_init); + gaim_xfer_set_write_fnc(xfer, irc_dccsend_send_write); + gaim_xfer_set_end_fnc(xfer, irc_dccsend_send_destroy); + gaim_xfer_set_request_denied_fnc(xfer, irc_dccsend_send_destroy); + gaim_xfer_set_cancel_send_fnc(xfer, irc_dccsend_send_destroy); + } return xfer; }
--- a/libgaim/protocols/jabber/oob.c Thu Jan 04 19:21:10 2007 +0000 +++ b/libgaim/protocols/jabber/oob.c Thu Jan 04 23:20:12 2007 +0000 @@ -215,25 +215,28 @@ xfer = gaim_xfer_new(js->gc->account, GAIM_XFER_RECEIVE, xmlnode_get_attrib(packet, "from")); - xfer->data = jox; + if (xfer) + { + xfer->data = jox; - if(!(filename = g_strdup(g_strrstr(jox->page, "/")))) - filename = g_strdup(jox->page); + if(!(filename = g_strdup(g_strrstr(jox->page, "/")))) + filename = g_strdup(jox->page); - gaim_xfer_set_filename(xfer, filename); + gaim_xfer_set_filename(xfer, filename); - g_free(filename); + g_free(filename); - gaim_xfer_set_init_fnc(xfer, jabber_oob_xfer_init); - gaim_xfer_set_end_fnc(xfer, jabber_oob_xfer_end); - gaim_xfer_set_request_denied_fnc(xfer, jabber_oob_xfer_recv_denied); - gaim_xfer_set_cancel_recv_fnc(xfer, jabber_oob_xfer_recv_canceled); - gaim_xfer_set_read_fnc(xfer, jabber_oob_xfer_read); - gaim_xfer_set_start_fnc(xfer, jabber_oob_xfer_start); + gaim_xfer_set_init_fnc(xfer, jabber_oob_xfer_init); + gaim_xfer_set_end_fnc(xfer, jabber_oob_xfer_end); + gaim_xfer_set_request_denied_fnc(xfer, jabber_oob_xfer_recv_denied); + gaim_xfer_set_cancel_recv_fnc(xfer, jabber_oob_xfer_recv_canceled); + gaim_xfer_set_read_fnc(xfer, jabber_oob_xfer_read); + gaim_xfer_set_start_fnc(xfer, jabber_oob_xfer_start); - js->oob_file_transfers = g_list_append(js->oob_file_transfers, xfer); + js->oob_file_transfers = g_list_append(js->oob_file_transfers, xfer); - gaim_xfer_request(xfer); + gaim_xfer_request(xfer); + } }
--- a/libgaim/protocols/jabber/si.c Thu Jan 04 19:21:10 2007 +0000 +++ b/libgaim/protocols/jabber/si.c Thu Jan 04 23:20:12 2007 +0000 @@ -842,15 +842,17 @@ js = gc->proto_data; xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); - - xfer->data = jsx = g_new0(JabberSIXfer, 1); - jsx->js = js; + if (xfer) + { + xfer->data = jsx = g_new0(JabberSIXfer, 1); + jsx->js = js; - gaim_xfer_set_init_fnc(xfer, jabber_si_xfer_init); - gaim_xfer_set_cancel_send_fnc(xfer, jabber_si_xfer_cancel_send); - gaim_xfer_set_end_fnc(xfer, jabber_si_xfer_end); + gaim_xfer_set_init_fnc(xfer, jabber_si_xfer_init); + gaim_xfer_set_cancel_send_fnc(xfer, jabber_si_xfer_cancel_send); + gaim_xfer_set_end_fnc(xfer, jabber_si_xfer_end); - js->file_transfers = g_list_append(js->file_transfers, xfer); + js->file_transfers = g_list_append(js->file_transfers, xfer); + } return xfer; } @@ -950,20 +952,23 @@ jsx->iq_id = g_strdup(xmlnode_get_attrib(packet, "id")); xfer = gaim_xfer_new(js->gc->account, GAIM_XFER_RECEIVE, from); - xfer->data = jsx; + if (xfer) + { + xfer->data = jsx; - gaim_xfer_set_filename(xfer, filename); - if(filesize > 0) - gaim_xfer_set_size(xfer, filesize); + gaim_xfer_set_filename(xfer, filename); + if(filesize > 0) + gaim_xfer_set_size(xfer, filesize); - gaim_xfer_set_init_fnc(xfer, jabber_si_xfer_init); - gaim_xfer_set_request_denied_fnc(xfer, jabber_si_xfer_request_denied); - gaim_xfer_set_cancel_recv_fnc(xfer, jabber_si_xfer_cancel_recv); - gaim_xfer_set_end_fnc(xfer, jabber_si_xfer_end); + gaim_xfer_set_init_fnc(xfer, jabber_si_xfer_init); + gaim_xfer_set_request_denied_fnc(xfer, jabber_si_xfer_request_denied); + gaim_xfer_set_cancel_recv_fnc(xfer, jabber_si_xfer_cancel_recv); + gaim_xfer_set_end_fnc(xfer, jabber_si_xfer_end); - js->file_transfers = g_list_append(js->file_transfers, xfer); + js->file_transfers = g_list_append(js->file_transfers, xfer); - gaim_xfer_request(xfer); + gaim_xfer_request(xfer); + } }
--- a/libgaim/protocols/msn/msn.c Thu Jan 04 19:21:10 2007 +0000 +++ b/libgaim/protocols/msn/msn.c Thu Jan 04 23:20:12 2007 +0000 @@ -428,12 +428,14 @@ session = gc->proto_data; xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); - - slplink = msn_session_get_slplink(session, who); + if (xfer) + { + slplink = msn_session_get_slplink(session, who); - xfer->data = slplink; + xfer->data = slplink; - gaim_xfer_set_init_fnc(xfer, t_msn_xfer_init); + gaim_xfer_set_init_fnc(xfer, t_msn_xfer_init); + } return xfer; }
--- a/libgaim/protocols/msn/slp.c Thu Jan 04 19:21:10 2007 +0000 +++ b/libgaim/protocols/msn/slp.c Thu Jan 04 23:20:12 2007 +0000 @@ -339,31 +339,33 @@ xfer = gaim_xfer_new(account, GAIM_XFER_RECEIVE, slpcall->slplink->remote_user); - - bin = (char *)gaim_base64_decode(context, &bin_len); - file_size = GUINT32_FROM_LE(*((gsize *)bin + 2)); + if (xfer) + { + bin = (char *)gaim_base64_decode(context, &bin_len); + file_size = GUINT32_FROM_LE(*((gsize *)bin + 2)); - uni_name = (gunichar2 *)(bin + 20); - while(*uni_name != 0 && ((char *)uni_name - (bin + 20)) < MAX_FILE_NAME_LEN) { - *uni_name = GUINT16_FROM_LE(*uni_name); - uni_name++; - } + uni_name = (gunichar2 *)(bin + 20); + while(*uni_name != 0 && ((char *)uni_name - (bin + 20)) < MAX_FILE_NAME_LEN) { + *uni_name = GUINT16_FROM_LE(*uni_name); + uni_name++; + } - file_name = g_utf16_to_utf8((const gunichar2 *)(bin + 20), -1, - NULL, NULL, NULL); + file_name = g_utf16_to_utf8((const gunichar2 *)(bin + 20), -1, + NULL, NULL, NULL); - g_free(bin); + g_free(bin); - gaim_xfer_set_filename(xfer, file_name); - gaim_xfer_set_size(xfer, file_size); - gaim_xfer_set_init_fnc(xfer, msn_xfer_init); - gaim_xfer_set_request_denied_fnc(xfer, msn_xfer_cancel); - gaim_xfer_set_cancel_recv_fnc(xfer, msn_xfer_cancel); + gaim_xfer_set_filename(xfer, file_name); + gaim_xfer_set_size(xfer, file_size); + gaim_xfer_set_init_fnc(xfer, msn_xfer_init); + gaim_xfer_set_request_denied_fnc(xfer, msn_xfer_cancel); + gaim_xfer_set_cancel_recv_fnc(xfer, msn_xfer_cancel); - slpcall->xfer = xfer; - xfer->data = slpcall; + slpcall->xfer = xfer; + xfer->data = slpcall; - gaim_xfer_request(xfer); + gaim_xfer_request(xfer); + } } }
--- a/libgaim/protocols/oscar/oscar.c Thu Jan 04 19:21:10 2007 +0000 +++ b/libgaim/protocols/oscar/oscar.c Thu Jan 04 23:20:12 2007 +0000 @@ -6308,18 +6308,21 @@ account = gaim_connection_get_account(gc); xfer = gaim_xfer_new(account, GAIM_XFER_SEND, who); - gaim_xfer_ref(xfer); - gaim_xfer_set_init_fnc(xfer, peer_oft_sendcb_init); - gaim_xfer_set_cancel_send_fnc(xfer, peer_oft_cb_generic_cancel); - gaim_xfer_set_request_denied_fnc(xfer, peer_oft_cb_generic_cancel); - gaim_xfer_set_ack_fnc(xfer, peer_oft_sendcb_ack); - - conn = peer_connection_new(od, OSCAR_CAPABILITY_SENDFILE, who); - conn->flags |= PEER_CONNECTION_FLAG_INITIATED_BY_ME; - conn->flags |= PEER_CONNECTION_FLAG_APPROVED; - aim_icbm_makecookie(conn->cookie); - conn->xfer = xfer; - xfer->data = conn; + if (xfer) + { + gaim_xfer_ref(xfer); + gaim_xfer_set_init_fnc(xfer, peer_oft_sendcb_init); + gaim_xfer_set_cancel_send_fnc(xfer, peer_oft_cb_generic_cancel); + gaim_xfer_set_request_denied_fnc(xfer, peer_oft_cb_generic_cancel); + gaim_xfer_set_ack_fnc(xfer, peer_oft_sendcb_ack); + + conn = peer_connection_new(od, OSCAR_CAPABILITY_SENDFILE, who); + conn->flags |= PEER_CONNECTION_FLAG_INITIATED_BY_ME; + conn->flags |= PEER_CONNECTION_FLAG_APPROVED; + aim_icbm_makecookie(conn->cookie); + conn->xfer = xfer; + xfer->data = conn; + } return xfer; }
--- a/libgaim/protocols/oscar/peer.c Thu Jan 04 19:21:10 2007 +0000 +++ b/libgaim/protocols/oscar/peer.c Thu Jan 04 23:20:12 2007 +0000 @@ -1022,52 +1022,55 @@ gchar *filename; conn->xfer = gaim_xfer_new(account, GAIM_XFER_RECEIVE, sn); - conn->xfer->data = conn; - gaim_xfer_ref(conn->xfer); - gaim_xfer_set_size(conn->xfer, args->info.sendfile.totsize); + if (conn->xfer) + { + conn->xfer->data = conn; + gaim_xfer_ref(conn->xfer); + gaim_xfer_set_size(conn->xfer, args->info.sendfile.totsize); - /* Set the file name */ - if (g_utf8_validate(args->info.sendfile.filename, -1, NULL)) - filename = g_strdup(args->info.sendfile.filename); - else - filename = gaim_utf8_salvage(args->info.sendfile.filename); + /* Set the file name */ + if (g_utf8_validate(args->info.sendfile.filename, -1, NULL)) + filename = g_strdup(args->info.sendfile.filename); + else + filename = gaim_utf8_salvage(args->info.sendfile.filename); - if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) - { + if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) + { + /* + * If they are sending us a directory then the last character + * of the file name will be an asterisk. We don't want to + * save stuff to a directory named "*" so we remove the + * asterisk from the file name. + */ + char *tmp = strrchr(filename, '\\'); + if ((tmp != NULL) && (tmp[1] == '*')) + tmp[0] = '\0'; + } + gaim_xfer_set_filename(conn->xfer, filename); + g_free(filename); + /* - * If they are sending us a directory then the last character - * of the file name will be an asterisk. We don't want to - * save stuff to a directory named "*" so we remove the - * asterisk from the file name. + * Set the message, unless this is the dummy message from an + * ICQ client or an empty message from an AIM client. + * TODO: Maybe we should strip HTML and then see if strlen>0? */ - char *tmp = strrchr(filename, '\\'); - if ((tmp != NULL) && (tmp[1] == '*')) - tmp[0] = '\0'; + if ((message != NULL) && + (g_ascii_strncasecmp(message, "<ICQ_COOL_FT>", 13) != 0) && + (g_ascii_strcasecmp(message, "<HTML>") != 0)) + { + gaim_xfer_set_message(conn->xfer, message); + } + + /* Setup our I/O op functions */ + gaim_xfer_set_init_fnc(conn->xfer, peer_oft_recvcb_init); + gaim_xfer_set_end_fnc(conn->xfer, peer_oft_recvcb_end); + gaim_xfer_set_request_denied_fnc(conn->xfer, peer_oft_cb_generic_cancel); + gaim_xfer_set_cancel_recv_fnc(conn->xfer, peer_oft_cb_generic_cancel); + gaim_xfer_set_ack_fnc(conn->xfer, peer_oft_recvcb_ack_recv); + + /* Now perform the request */ + gaim_xfer_request(conn->xfer); } - gaim_xfer_set_filename(conn->xfer, filename); - g_free(filename); - - /* - * Set the message (unless this is the dummy message from an - * ICQ client or an empty message from an AIM client. - * TODO: Maybe we should strip HTML and then see if strlen>0? - */ - if ((message != NULL) && - (g_ascii_strncasecmp(message, "<ICQ_COOL_FT>", 13) != 0) && - (g_ascii_strcasecmp(message, "<HTML>") != 0)) - { - gaim_xfer_set_message(conn->xfer, message); - } - - /* Setup our I/O op functions */ - gaim_xfer_set_init_fnc(conn->xfer, peer_oft_recvcb_init); - gaim_xfer_set_end_fnc(conn->xfer, peer_oft_recvcb_end); - gaim_xfer_set_request_denied_fnc(conn->xfer, peer_oft_cb_generic_cancel); - gaim_xfer_set_cancel_recv_fnc(conn->xfer, peer_oft_cb_generic_cancel); - gaim_xfer_set_ack_fnc(conn->xfer, peer_oft_recvcb_ack_recv); - - /* Now perform the request */ - gaim_xfer_request(conn->xfer); } }
--- a/libgaim/protocols/qq/send_file.c Thu Jan 04 19:21:10 2007 +0000 +++ b/libgaim/protocols/qq/send_file.c Thu Jan 04 23:20:12 2007 +0000 @@ -841,19 +841,22 @@ xfer = gaim_xfer_new(gaim_connection_get_account(gc), GAIM_XFER_RECEIVE, sender_name); - gaim_xfer_set_filename(xfer, fileinfo[0]); - gaim_xfer_set_size(xfer, atoi(fileinfo[1])); + if (xfer) + { + gaim_xfer_set_filename(xfer, fileinfo[0]); + gaim_xfer_set_size(xfer, atoi(fileinfo[1])); - gaim_xfer_set_init_fnc(xfer, _qq_xfer_recv_init); - gaim_xfer_set_request_denied_fnc(xfer, _qq_xfer_cancel); - gaim_xfer_set_cancel_recv_fnc(xfer, _qq_xfer_cancel); - gaim_xfer_set_end_fnc(xfer, _qq_xfer_end); - gaim_xfer_set_write_fnc(xfer, _qq_xfer_write); + gaim_xfer_set_init_fnc(xfer, _qq_xfer_recv_init); + gaim_xfer_set_request_denied_fnc(xfer, _qq_xfer_cancel); + gaim_xfer_set_cancel_recv_fnc(xfer, _qq_xfer_cancel); + gaim_xfer_set_end_fnc(xfer, _qq_xfer_end); + gaim_xfer_set_write_fnc(xfer, _qq_xfer_write); - xfer->data = info; - qd->xfer = xfer; + xfer->data = info; + qd->xfer = xfer; - gaim_xfer_request(xfer); + gaim_xfer_request(xfer); + } g_free(sender_name); g_strfreev(fileinfo); @@ -920,12 +923,15 @@ xfer = gaim_xfer_new (gc->account, GAIM_XFER_SEND, who); - gaim_xfer_set_init_fnc (xfer, _qq_xfer_init); - gaim_xfer_set_cancel_send_fnc (xfer, _qq_xfer_cancel); - gaim_xfer_set_write_fnc(xfer, _qq_xfer_write); + if (xfer) + { + gaim_xfer_set_init_fnc (xfer, _qq_xfer_init); + gaim_xfer_set_cancel_send_fnc (xfer, _qq_xfer_cancel); + gaim_xfer_set_write_fnc(xfer, _qq_xfer_write); - qd->xfer = xfer; - gaim_xfer_request (xfer); + qd->xfer = xfer; + gaim_xfer_request(xfer); + } } /*
--- a/libgaim/protocols/sametime/sametime.c Thu Jan 04 19:21:10 2007 +0000 +++ b/libgaim/protocols/sametime/sametime.c Thu Jan 04 23:20:12 2007 +0000 @@ -2116,20 +2116,22 @@ DEBUG_INFO(" text: %s\n", NSTR(mwFileTransfer_getMessage(ft))); xfer = gaim_xfer_new(acct, GAIM_XFER_RECEIVE, who); - - gaim_xfer_ref(xfer); - mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) gaim_xfer_unref); - xfer->data = ft; - - gaim_xfer_set_init_fnc(xfer, ft_incoming_init); - gaim_xfer_set_cancel_recv_fnc(xfer, ft_incoming_cancel); - gaim_xfer_set_request_denied_fnc(xfer, ft_incoming_cancel); - - gaim_xfer_set_filename(xfer, mwFileTransfer_getFileName(ft)); - gaim_xfer_set_size(xfer, mwFileTransfer_getFileSize(ft)); - gaim_xfer_set_message(xfer, mwFileTransfer_getMessage(ft)); - - gaim_xfer_request(xfer); + if (xfer) + { + gaim_xfer_ref(xfer); + mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) gaim_xfer_unref); + xfer->data = ft; + + gaim_xfer_set_init_fnc(xfer, ft_incoming_init); + gaim_xfer_set_cancel_recv_fnc(xfer, ft_incoming_cancel); + gaim_xfer_set_request_denied_fnc(xfer, ft_incoming_cancel); + + gaim_xfer_set_filename(xfer, mwFileTransfer_getFileName(ft)); + gaim_xfer_set_size(xfer, mwFileTransfer_getFileSize(ft)); + gaim_xfer_set_message(xfer, mwFileTransfer_getMessage(ft)); + + gaim_xfer_request(xfer); + } } @@ -5056,9 +5058,12 @@ acct = gaim_connection_get_account(gc); xfer = gaim_xfer_new(acct, GAIM_XFER_SEND, who); - gaim_xfer_set_init_fnc(xfer, ft_outgoing_init); - gaim_xfer_set_cancel_send_fnc(xfer, ft_outgoing_cancel); - + if (xfer) + { + gaim_xfer_set_init_fnc(xfer, ft_outgoing_init); + gaim_xfer_set_cancel_send_fnc(xfer, ft_outgoing_cancel); + } + return xfer; }
--- a/libgaim/protocols/yahoo/yahoo_filexfer.c Thu Jan 04 19:21:10 2007 +0000 +++ b/libgaim/protocols/yahoo/yahoo_filexfer.c Thu Jan 04 23:20:12 2007 +0000 @@ -575,43 +575,46 @@ /* Build the file transfer handle. */ xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, from); - xfer->data = xfer_data; + if (xfer) + { + xfer->data = xfer_data; - /* Set the info about the incoming file. */ - if (filename) { - char *utf8_filename = yahoo_string_decode(gc, filename, TRUE); - gaim_xfer_set_filename(xfer, utf8_filename); - g_free(utf8_filename); - } else { - gchar *start, *end; - start = g_strrstr(xfer_data->path, "/"); - if (start) - start++; - end = g_strrstr(xfer_data->path, "?"); - if (start && *start && end) { - char *utf8_filename; - filename = g_strndup(start, end - start); - utf8_filename = yahoo_string_decode(gc, filename, TRUE); - g_free(filename); + /* Set the info about the incoming file. */ + if (filename) { + char *utf8_filename = yahoo_string_decode(gc, filename, TRUE); gaim_xfer_set_filename(xfer, utf8_filename); g_free(utf8_filename); - filename = NULL; + } else { + gchar *start, *end; + start = g_strrstr(xfer_data->path, "/"); + if (start) + start++; + end = g_strrstr(xfer_data->path, "?"); + if (start && *start && end) { + char *utf8_filename; + filename = g_strndup(start, end - start); + utf8_filename = yahoo_string_decode(gc, filename, TRUE); + g_free(filename); + gaim_xfer_set_filename(xfer, utf8_filename); + g_free(utf8_filename); + filename = NULL; + } } - } - - gaim_xfer_set_size(xfer, filesize); - /* Setup our I/O op functions */ - gaim_xfer_set_init_fnc(xfer, yahoo_xfer_init); - gaim_xfer_set_start_fnc(xfer, yahoo_xfer_start); - gaim_xfer_set_end_fnc(xfer, yahoo_xfer_end); - gaim_xfer_set_cancel_send_fnc(xfer, yahoo_xfer_cancel_send); - gaim_xfer_set_cancel_recv_fnc(xfer, yahoo_xfer_cancel_recv); - gaim_xfer_set_read_fnc(xfer, yahoo_xfer_read); - gaim_xfer_set_write_fnc(xfer, yahoo_xfer_write); + gaim_xfer_set_size(xfer, filesize); - /* Now perform the request */ - gaim_xfer_request(xfer); + /* Setup our I/O op functions */ + gaim_xfer_set_init_fnc(xfer, yahoo_xfer_init); + gaim_xfer_set_start_fnc(xfer, yahoo_xfer_start); + gaim_xfer_set_end_fnc(xfer, yahoo_xfer_end); + gaim_xfer_set_cancel_send_fnc(xfer, yahoo_xfer_cancel_send); + gaim_xfer_set_cancel_recv_fnc(xfer, yahoo_xfer_cancel_recv); + gaim_xfer_set_read_fnc(xfer, yahoo_xfer_read); + gaim_xfer_set_write_fnc(xfer, yahoo_xfer_write); + + /* Now perform the request */ + gaim_xfer_request(xfer); + } } GaimXfer *yahoo_new_xfer(GaimConnection *gc, const char *who) @@ -626,16 +629,19 @@ /* Build the file transfer handle. */ xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); - xfer->data = xfer_data; - - /* Setup our I/O op functions */ - gaim_xfer_set_init_fnc(xfer, yahoo_xfer_init); - gaim_xfer_set_start_fnc(xfer, yahoo_xfer_start); - gaim_xfer_set_end_fnc(xfer, yahoo_xfer_end); - gaim_xfer_set_cancel_send_fnc(xfer, yahoo_xfer_cancel_send); - gaim_xfer_set_cancel_recv_fnc(xfer, yahoo_xfer_cancel_recv); - gaim_xfer_set_read_fnc(xfer, yahoo_xfer_read); - gaim_xfer_set_write_fnc(xfer, yahoo_xfer_write); + if (xfer) + { + xfer->data = xfer_data; + + /* Setup our I/O op functions */ + gaim_xfer_set_init_fnc(xfer, yahoo_xfer_init); + gaim_xfer_set_start_fnc(xfer, yahoo_xfer_start); + gaim_xfer_set_end_fnc(xfer, yahoo_xfer_end); + gaim_xfer_set_cancel_send_fnc(xfer, yahoo_xfer_cancel_send); + gaim_xfer_set_cancel_recv_fnc(xfer, yahoo_xfer_cancel_recv); + gaim_xfer_set_read_fnc(xfer, yahoo_xfer_read); + gaim_xfer_set_write_fnc(xfer, yahoo_xfer_write); + } return xfer; }