im.pidgin.pidgin: bfc4df11256d088d75b0512bb0c4790967b68b19

datallah at pidgin.im datallah at pidgin.im
Wed Jan 9 14:16:04 EST 2008


-----------------------------------------------------------------
Revision: bfc4df11256d088d75b0512bb0c4790967b68b19
Ancestor: bb4f5934f047bb1663dc3f5c981287aee020e3ef
Author: datallah at pidgin.im
Date: 2008-01-09T19:10:27
Branch: im.pidgin.pidgin

Modified files:
        libpurple/protocols/yahoo/yahoo.c

ChangeLog: 

Fix a crash when accepting/denying a yahoo auth. request when the account is disconnected. References #4581

-------------- next part --------------
============================================================
--- libpurple/protocols/yahoo/yahoo.c	6cdb54f25d9518f09c4b1b9aed970201745e54e6
+++ libpurple/protocols/yahoo/yahoo.c	de6d0d0b89965692c0344a3d0dd1edd3a65ff635
@@ -970,13 +970,19 @@ yahoo_buddy_add_authorize_cb(gpointer da
 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;
+	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);
+		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,29 +991,32 @@ yahoo_buddy_add_deny_cb(struct yahoo_add
 
 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);
+	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);
 
-	pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15,
-			YAHOO_STATUS_AVAILABLE, 0);
+		if (msg && *msg)
+			encoded_msg = yahoo_string_encode(add_req->gc, msg, NULL);
 
-	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 : "");
+		pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15,
+				YAHOO_STATUS_AVAILABLE, 0);
 
-	yahoo_packet_send_and_free(pkt, yd);
+		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 : "");
 
-	g_free(encoded_msg);
+		yahoo_packet_send_and_free(pkt, yd);
 
+		g_free(encoded_msg);
+	}
+
 	g_free(add_req->id);
 	g_free(add_req->who);
 	g_free(add_req);


More information about the Commits mailing list