changeset 26263:c67bf2e1e6c0

Handle multiple 319 (channels joined) messages for IRC WHOIS. This additionally fixes a leak when multiple 319 messages were received. Fixes #8827
author Ethan Blanton <elb@pidgin.im>
date Tue, 31 Mar 2009 01:08:29 +0000
parents 5e5494482f01
children 6821f507ae26
files libpurple/protocols/irc/irc.h libpurple/protocols/irc/msgs.c
diffstat 2 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/irc/irc.h	Mon Mar 30 05:52:32 2009 +0000
+++ b/libpurple/protocols/irc/irc.h	Tue Mar 31 01:08:29 2009 +0000
@@ -72,7 +72,7 @@
 		char *name;
 		char *server;
 		char *serverinfo;
-		char *channels;
+		GString *channels;
 		int ircop;
 		int identified;
 		int idle;
--- a/libpurple/protocols/irc/msgs.c	Mon Mar 30 05:52:32 2009 +0000
+++ b/libpurple/protocols/irc/msgs.c	Tue Mar 31 01:08:29 2009 +0000
@@ -336,7 +336,11 @@
 		if (args[3])
 			irc->whois.signon = (time_t)atoi(args[3]);
 	} else if (!strcmp(name, "319")) {
-		irc->whois.channels = g_strdup(args[2]);
+		if (irc->whois.channels == NULL) {
+			irc->whois.channels = g_string_new(args[2]);
+		} else {
+			irc->whois.channels = g_string_append(irc->whois.channels, args[2]);
+		}
 	} else if (!strcmp(name, "320")) {
 		irc->whois.identified = 1;
 	}
@@ -391,8 +395,8 @@
 		g_free(irc->whois.serverinfo);
 	}
 	if (irc->whois.channels) {
-		purple_notify_user_info_add_pair(user_info, _("Currently on"), irc->whois.channels);
-		g_free(irc->whois.channels);
+		purple_notify_user_info_add_pair(user_info, _("Currently on"), irc->whois.channels->str);
+		g_string_free(irc->whois.channels, TRUE);
 	}
 	if (irc->whois.idle) {
 		gchar *timex = purple_str_seconds_to_string(irc->whois.idle);