changeset 30327:06d8de5dd53c

yahoo: Avoid misuse of purple_normalize purple_normalize returns a pointer into a static buffer, so calling it twice in the arguments to another function is bad. (It was OK in this case, since the two calls were identical, but let's avoid bad idioms)
author Paul Aurich <paul@darkrain42.org>
date Sun, 01 Aug 2010 20:21:20 +0000
parents 2244a84407a4
children 94f8a42e529b
files libpurple/protocols/yahoo/libymsg.c
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/libymsg.c	Sun Aug 01 03:23:24 2010 +0000
+++ b/libpurple/protocols/yahoo/libymsg.c	Sun Aug 01 20:21:20 2010 +0000
@@ -2702,6 +2702,7 @@
 	PurpleAccount *account;
 	YahooData *yd = gc->proto_data;
 	struct yahoo_p2p_data *p2p_data;
+	const char *norm_username;
 
 	f = yahoo_friend_find(gc, who);
 	account = purple_connection_get_account(gc);
@@ -2734,10 +2735,11 @@
 	sprintf(temp_str, "%d", ip);
 	base64_ip = purple_base64_encode( (guchar *)temp_str, strlen(temp_str) );
 
+	norm_username = purple_normalize(account, purple_account_get_username(account));
 	pkt = yahoo_packet_new(YAHOO_SERVICE_PEERTOPEER, YAHOO_STATUS_AVAILABLE, 0);
 	yahoo_packet_hash(pkt, "sssissis",
-		1, purple_normalize(account, purple_account_get_username(account)),
-		4, purple_normalize(account, purple_account_get_username(account)),
+		1, norm_username,
+		4, norm_username,
 		12, base64_ip,	/* base64 encode ip */
 		61, 0,		/* To-do : figure out what is 61 for?? */
 		2, "",