Rearrange code to prevent a NULL-deference. Thanks to clh for
authorElliott Sales de Andrade <qulogic@pidgin.im>
Thu, 22 Dec 2011 01:13:20 +0000
changeset92fdfe84de21 pushlog
parent c5074dd18f4d
child 8ccddc6bfc19
Rearrange code to prevent a NULL-deference. Thanks to clh for
pointing out this issue.

Closes #14392.
pidgin/gtkconv.c
     1.1 --- a/pidgin/gtkconv.c
     1.2 +++ b/pidgin/gtkconv.c
     1.3 @@ -6624,23 +6624,23 @@
     1.4  	if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter))
     1.5  		return;
     1.6  
     1.7 -	old_cbuddy = purple_conv_chat_cb_find(chat, old_name);
     1.8 -	if (get_iter_from_chatbuddy(old_cbuddy, &iter)) {
     1.9 -		GtkTreeRowReference *ref = purple_conv_chat_cb_get_ui_data(old_cbuddy);
    1.10 -
    1.11 -		gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
    1.12 -		gtk_tree_row_reference_free(ref);
    1.13 -		purple_conv_chat_cb_set_ui_data(old_cbuddy, NULL);
    1.14 -	}
    1.15 -
    1.16  	if ((tag = get_buddy_tag(conv, old_name, 0, FALSE)))
    1.17  		g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_ITALIC, NULL);
    1.18  	if ((tag = get_buddy_tag(conv, old_name, PURPLE_MESSAGE_NICK, FALSE)))
    1.19  		g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_ITALIC, NULL);
    1.20  
    1.21 +	old_cbuddy = purple_conv_chat_cb_find(chat, old_name);
    1.22  	if (!old_cbuddy)
    1.23  		return;
    1.24  
    1.25 +	if (get_iter_from_chatbuddy(old_cbuddy, &iter)) {
    1.26 +		GtkTreeRowReference *ref = purple_conv_chat_cb_get_ui_data(old_cbuddy);
    1.27 +
    1.28 +		gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
    1.29 +		gtk_tree_row_reference_free(ref);
    1.30 +		purple_conv_chat_cb_set_ui_data(old_cbuddy, NULL);
    1.31 +	}
    1.32 +
    1.33  	g_return_if_fail(new_alias != NULL);
    1.34  
    1.35  	new_cbuddy = purple_conv_chat_cb_find(chat, new_name);