changeset 31652:258fec7797b9

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
author Mark Doliner <mark@kingant.net>
date Mon, 14 Feb 2011 01:01:37 +0000
parents 1b1f9d6b25d0
children f1874b08b3f9
files libpurple/protocols/myspace/myspace.c
diffstat 1 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/myspace/myspace.c	Sat Feb 12 16:27:10 2011 +0000
+++ b/libpurple/protocols/myspace/myspace.c	Mon Feb 14 01:01:37 2011 +0000
@@ -385,21 +385,22 @@
 
 	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;
-	}
-
-	if (purple_account_get_bool(session->account, "show_display_name", FALSE)) {
-		display_name = user->display_name;
+	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(account, "show_display_name", FALSE)) {
+			display_name = user->display_name;
+		}
 	}
 
 	/* Return appropriate combination of display name and/or headline, or neither. */