# HG changeset patch # User Mark Doliner # Date 1297645297 0 # Node ID 258fec7797b9b36c07d02f2b54a5b01a9fee6e90 # Parent 1b1f9d6b25d07fcd2c4470fc742ca80c822b3133 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 diff -r 1b1f9d6b25d0 -r 258fec7797b9 libpurple/protocols/myspace/myspace.c --- 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. */