Mercurial > pidgin
changeset 22053:40a70eb8edb1
Fix a crash when accepting/denying a yahoo auth. request when the account is disconnected. References #4581
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Wed, 09 Jan 2008 19:10:27 +0000 |
parents | 1be0d49532a1 |
children | 658785fe1992 |
files | libpurple/protocols/yahoo/yahoo.c |
diffstat | 1 files changed, 38 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/yahoo.c Wed Jan 09 19:07:16 2008 +0000 +++ b/libpurple/protocols/yahoo/yahoo.c Wed Jan 09 19:10:27 2008 +0000 @@ -970,13 +970,19 @@ yahoo_buddy_add_authorize_cb(gpointer data) { struct yahoo_add_request *add_req = data; - struct yahoo_packet *pkt; - struct yahoo_data *yd = add_req->gc->proto_data; - - pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15, YAHOO_STATUS_AVAILABLE, 0); - yahoo_packet_hash(pkt, "ssiii", 1, add_req->id, 5, add_req->who, 241, add_req->protocol, - 13, 1, 334, 0); - yahoo_packet_send_and_free(pkt, yd); + if (PURPLE_CONNECTION_IS_VALID(add_req->gc)) { + struct yahoo_packet *pkt; + struct yahoo_data *yd = add_req->gc->proto_data; + + pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15, YAHOO_STATUS_AVAILABLE, 0); + yahoo_packet_hash(pkt, "ssiii", + 1, add_req->id, + 5, add_req->who, + 241, add_req->protocol, + 13, 1, + 334, 0); + yahoo_packet_send_and_free(pkt, yd); + } g_free(add_req->id); g_free(add_req->who); @@ -985,28 +991,31 @@ static void yahoo_buddy_add_deny_cb(struct yahoo_add_request *add_req, const char *msg) { - struct yahoo_packet *pkt; - char *encoded_msg = NULL; - struct yahoo_data *yd = add_req->gc->proto_data; - PurpleAccount *account = purple_connection_get_account(add_req->gc); - - if (msg && *msg) - encoded_msg = yahoo_string_encode(add_req->gc, msg, NULL); - - pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15, - YAHOO_STATUS_AVAILABLE, 0); - - yahoo_packet_hash(pkt, "ssiiis", - 1, purple_normalize(account, purple_account_get_username(account)), - 5, add_req->who, - 13, 2, - 334, 0, - 97, 1, - 14, encoded_msg ? encoded_msg : ""); - - yahoo_packet_send_and_free(pkt, yd); - - g_free(encoded_msg); + + if (PURPLE_CONNECTION_IS_VALID(add_req->gc)) { + struct yahoo_data *yd = add_req->gc->proto_data; + struct yahoo_packet *pkt; + char *encoded_msg = NULL; + PurpleAccount *account = purple_connection_get_account(add_req->gc); + + if (msg && *msg) + encoded_msg = yahoo_string_encode(add_req->gc, msg, NULL); + + pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15, + YAHOO_STATUS_AVAILABLE, 0); + + yahoo_packet_hash(pkt, "ssiiis", + 1, purple_normalize(account, purple_account_get_username(account)), + 5, add_req->who, + 13, 2, + 334, 0, + 97, 1, + 14, encoded_msg ? encoded_msg : ""); + + yahoo_packet_send_and_free(pkt, yd); + + g_free(encoded_msg); + } g_free(add_req->id); g_free(add_req->who);