pidgin: ec6291ec: Fix a crash on receiving an offline mess...
sulabh at soc.pidgin.im
sulabh at soc.pidgin.im
Sat Oct 24 04:00:50 EDT 2009
-----------------------------------------------------------------
Revision: ec6291ec02cfa2c94de6aedf7b94c48385ac65ef
Ancestor: 5f34ca8ecb9f3ed36f1b66300ecfd2197e0e8243
Author: sulabh at soc.pidgin.im
Date: 2009-10-24T04:10:23
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/ec6291ec02cfa2c94de6aedf7b94c48385ac65ef
Modified files:
libpurple/protocols/yahoo/libymsg.c
ChangeLog:
Fix a crash on receiving an offline message from a federated buddy. Also handle federated buddy per IM. Refs #9814
-------------- next part --------------
============================================================
--- libpurple/protocols/yahoo/libymsg.c 42c3ad231f84c9ce00c9d4df11076394ad549a2d
+++ libpurple/protocols/yahoo/libymsg.c f7d613e8962e7f16832782661126d33a897d7c1b
@@ -879,6 +879,7 @@ struct _yahoo_im {
char *id;
char *msg;
YahooFederation fed;
+ char *fed_from;
};
static void yahoo_process_sms_message(PurpleConnection *gc, struct yahoo_packet *pkt)
@@ -952,7 +953,6 @@ static void yahoo_process_message(Purple
struct _yahoo_im *im = NULL;
const char *imv = NULL;
gint val_11 = 0;
- char *fed_from = NULL;
account = purple_connection_get_account(gc);
@@ -963,10 +963,11 @@ static void yahoo_process_message(Purple
if (pair->key == 4 || pair->key == 1) {
im = g_new0(struct _yahoo_im, 1);
list = g_slist_append(list, im);
- im->from = fed_from = pair->value;
+ im->from = pair->value;
im->time = time(NULL);
im->utf8 = TRUE;
im->fed = YAHOO_FEDERATION_NONE;
+ im->fed_from = g_strdup(im->from);
}
if (im && pair->key == 5)
im->active_id = pair->value;
@@ -985,21 +986,23 @@ static void yahoo_process_message(Purple
}
if (im && pair->key == 241) {
im->fed = strtol(pair->value, NULL, 10);
+ g_free(im->fed_from);
switch (im->fed) {
case YAHOO_FEDERATION_MSN:
- fed_from = g_strconcat("msn/",im->from, NULL);
+ im->fed_from = g_strconcat("msn/",im->from, NULL);
break;
case YAHOO_FEDERATION_OCS:
- fed_from = g_strconcat("ocs/",im->from, NULL);
+ im->fed_from = g_strconcat("ocs/",im->from, NULL);
break;
case YAHOO_FEDERATION_IBM:
- fed_from = g_strconcat("ibm/",im->from, NULL);
+ im->fed_from = g_strconcat("ibm/",im->from, NULL);
break;
case YAHOO_FEDERATION_NONE:
default:
+ im->fed_from = g_strdup(im->from);
break;
}
- purple_debug_info("yahoo", "Message from federated (%d) buddy %s.\n", im->fed, fed_from);
+ purple_debug_info("yahoo", "Message from federated (%d) buddy %s.\n", im->fed, im->fed_from);
}
/* peer session id */
@@ -1024,10 +1027,10 @@ static void yahoo_process_message(Purple
/* disconnect the peer if connected through p2p and sends wrong value for session id */
if( (pkt_type == YAHOO_PKT_TYPE_P2P) && (val_11 != yd->session_id) ) {
- purple_debug_warning("yahoo","p2p: %s sent us message with wrong session id. Disconnecting p2p connection to peer\n", im ? fed_from : "(im was null)");
+ purple_debug_warning("yahoo","p2p: %s sent us message with wrong session id. Disconnecting p2p connection to peer\n", im ? im->fed_from : "(im was null)");
/* remove from p2p connection lists, also calls yahoo_p2p_disconnect_destroy_data */
if (im) {
- g_hash_table_remove(yd->peers, fed_from);
+ g_hash_table_remove(yd->peers, im->fed_from);
g_free(im);
}
return;
@@ -1072,13 +1075,14 @@ static void yahoo_process_message(Purple
char *m, *m2;
im = l->data;
- if (!fed_from || !im->msg) {
+ if (!im->fed_from || !im->msg) {
+ g_free(im->fed_from);
g_free(im);
continue;
}
- if (!purple_privacy_check(account, fed_from)) {
- purple_debug_info("yahoo", "Message from %s dropped.\n", fed_from);
+ if (!purple_privacy_check(account, im->fed_from)) {
+ purple_debug_info("yahoo", "Message from %s dropped.\n", im->fed_from);
return;
}
@@ -1116,10 +1120,11 @@ static void yahoo_process_message(Purple
if (!strcmp(m, "<ding>")) {
char *username;
- username = g_markup_escape_text(fed_from, -1);
+ username = g_markup_escape_text(im->fed_from, -1);
purple_prpl_got_attention(gc, username, YAHOO_BUZZ);
g_free(username);
g_free(m);
+ g_free(im->fed_from);
g_free(im);
continue;
}
@@ -1127,7 +1132,7 @@ static void yahoo_process_message(Purple
m2 = yahoo_codes_to_html(m);
g_free(m);
- serv_got_im(gc, fed_from, m2, 0, im->time);
+ serv_got_im(gc, im->fed_from, m2, 0, im->time);
g_free(m2);
/* Official clients don't share buddy images with federated buddies */
@@ -1140,9 +1145,7 @@ static void yahoo_process_message(Purple
}
}
- if(im->fed != YAHOO_FEDERATION_NONE)
- g_free(fed_from);
-
+ g_free(im->fed_from);
g_free(im);
}
More information about the Commits
mailing list