pidgin: 53e17627: Attempt to fix a crash I've seen a few t...

markdoliner at pidgin.im markdoliner at pidgin.im
Sun Feb 13 20:06:02 EST 2011


----------------------------------------------------------------------
Revision: 53e17627a3ac9c40d0047fbc5efb15aa909c1f06
Parent:   c22777dae7e766426b17df35dbf42ba6d49bf820
Author:   markdoliner at pidgin.im
Date:     02/13/11 20:01:37
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/53e17627a3ac9c40d0047fbc5efb15aa909c1f06

Changelog: 

Attempt to fix a crash I've seen a few times.  I think it happens if you
have a conversation window open with a MySpace buddy, then your MySpace
account goes offline.  We apparently call the prpl's status_text prpl
function to get the status text for the buddy, but the connection is
offline.  I don't know if that's something we SHOULD do or not... but
other prpl's seem to handle this, at least.

1. Use buddy->account instead of buddy->account->gc->proto_data->account,
   since the former should always exist and later doesn't exist if the
   account is offline.  This was leading to a null pointer dereference.
2. Pass FALSE to msim_get_user_from_buddy() so that it will stop creating
   an MsimUser struct if one doesn't exist.  Creating it didn't accomplish
   anything, and I feel like it might never get freed if the account is
   already offline.
3. Put the checks for user->headline and user->display_name in a big
   if condition, so we won't try to grab that info if user is NULL

Changes against parent c22777dae7e766426b17df35dbf42ba6d49bf820

  patched  libpurple/protocols/myspace/myspace.c

-------------- next part --------------
============================================================
--- libpurple/protocols/myspace/myspace.c	6462f2cb353af2649c37d9c2e8634badca244de5
+++ libpurple/protocols/myspace/myspace.c	7997b286db5a4dc91d3584fea6701d23bb9c7f49
@@ -385,21 +385,22 @@ msim_status_text(PurpleBuddy *buddy)
 
 	g_return_val_if_fail(buddy != NULL, NULL);
 
-	user = msim_get_user_from_buddy(buddy, TRUE);
-
 	account = purple_buddy_get_account(buddy);
 	gc = purple_account_get_connection(account);
 	session = (MsimSession *)gc->proto_data;
 
 	display_name = headline = NULL;
 
-	/* Retrieve display name and/or headline, depending on user preference. */
-	if (purple_account_get_bool(session->account, "show_headline", TRUE)) {
-		headline = user->headline;
-	}
+	user = msim_get_user_from_buddy(buddy, FALSE);
+	if (user != NULL) {
+		/* Retrieve display name and/or headline, depending on user preference. */
+		if (purple_account_get_bool(account, "show_headline", TRUE)) {
+			headline = user->headline;
+		}
 
-	if (purple_account_get_bool(session->account, "show_display_name", FALSE)) {
-		display_name = user->display_name;
+		if (purple_account_get_bool(account, "show_display_name", FALSE)) {
+			display_name = user->display_name;
+		}
 	}
 
 	/* Return appropriate combination of display name and/or headline, or neither. */


More information about the Commits mailing list