changeset 27799:2fa28896c318

import fix for serv_got_* things
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Mon, 17 Mar 2008 06:15:43 +0000
parents 0298bd08da84
children 85d5b6c06a6c
files libpurple/server.c
diffstat 1 files changed, 17 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/server.c	Mon Mar 17 06:14:40 2008 +0000
+++ b/libpurple/server.c	Mon Mar 17 06:15:43 2008 +0000
@@ -236,14 +236,14 @@
 }
 
 void
-serv_got_alias(PurpleConnection *gc, const char *who, const char *alias_src)
+serv_got_alias(PurpleConnection *gc, const char *who, const char *alias)
 {
 	PurpleAccount *account;
 	GSList *buddies;
 	PurpleBuddy *b;
 	PurpleConversation *conv;
 	gsize dummy;
-	gchar *alias = sanitize_utf(alias_src, strlen(alias_src), &dummy);
+	gchar *alias2 = NULL;
 
 	account = purple_connection_get_account(gc);
 	buddies = purple_find_buddies(account, who);
@@ -253,19 +253,23 @@
 		b = buddies->data;
 		buddies = g_slist_delete_link(buddies, buddies);
 
+		/* alias may be NULL */
 		if((b->server_alias == NULL && alias == NULL) ||
 		    (b->server_alias && alias && !strcmp(b->server_alias, alias)))
 		{
 			continue;
 		}
 
-		purple_blist_server_alias_buddy(b, alias);
+		/* alias must be non-NULL here */
+		alias2 = sanitize_utf(alias, strlen(alias), &dummy);
+
+		purple_blist_server_alias_buddy(b, alias2);
 
 		conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, b->name, account);
-		if(conv != NULL && alias != NULL && strcmp(alias, who))
+		if(conv != NULL && alias2 != NULL && strcmp(alias2, who))
 		{
 			char *tmp = g_strdup_printf(_("%s is now known as %s.\n"),
-										who, alias);
+										who, alias2);
 
 			purple_conversation_write(conv, NULL, tmp,
 					PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LINKIFY,
@@ -273,18 +277,19 @@
 
 			g_free(tmp);
 		}
+		g_free(alias2);
+		alias2 = NULL;
 	}
-	g_free(alias);
 }
 
 void
-purple_serv_got_private_alias(PurpleConnection *gc, const char *who, const char *alias_src)
+purple_serv_got_private_alias(PurpleConnection *gc, const char *who, const char *alias)
 {
 	PurpleAccount *account = NULL;
 	GSList *buddies = NULL;
 	PurpleBuddy *b = NULL;
 	gsize dummy;
-	gchar *alias = sanitize_utf(alias_src, strlen(alias_src), &dummy);
+	gchar *alias2 = NULL;
 
 	account = purple_connection_get_account(gc);
 	buddies = purple_find_buddies(account, who);
@@ -297,12 +302,13 @@
 		if((!b->alias && !alias) || (b->alias && alias && !strcmp(b->alias, alias)))
 			continue;
 
-		purple_blist_alias_buddy(b, alias);
+		alias2 = sanitize_utf(alias, strlen(alias), &dummy);
+		purple_blist_alias_buddy(b, alias2);
+		g_free(alias2);
+		alias2 = NULL;
 	}
-	g_free(alias);
 }
 
-
 PurpleAttentionType *purple_get_attention_type_from_code(PurpleAccount *account, guint type_code)
 {
 	PurplePlugin *prpl;