changeset 15626:0b16a4aa4e2b

Fixed 3 Jabber memory leaks: in jabber_roster_parse(), there's no need to g_strdup() this normalized jid since it's only used immediately, and there was no correspoding g_free(). When removing an id from jbi->ids, its data should always be freed. Finally, gaim_str_seconds_to_string() returns retained memory -- we must free the returned pointer when we're done using it.
author Evan Schoenberg <evan.s@dreskin.net>
date Tue, 13 Feb 2007 22:19:26 +0000
parents fc586f7f23bd
children 68798ffeb321
files libpurple/protocols/jabber/buddy.c libpurple/protocols/jabber/roster.c
diffstat 2 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/buddy.c	Tue Feb 13 05:02:05 2007 +0000
+++ b/libpurple/protocols/jabber/buddy.c	Tue Feb 13 22:19:26 2007 +0000
@@ -642,7 +642,9 @@
 		}
 		if(jbir) {
 			if(jbir->idle_seconds > 0) {
-				gaim_notify_user_info_add_pair(user_info, _("Idle"), gaim_str_seconds_to_string(jbir->idle_seconds));
+				char *idle = gaim_str_seconds_to_string(jbir->idle_seconds);
+				gaim_notify_user_info_add_pair(user_info, _("Idle"), idle);
+				g_free(idle);
 			}
 		}
 		if(jbr && jbr->client.name) {
@@ -680,7 +682,9 @@
 
 			if(jbir) {
 				if(jbir->idle_seconds > 0) {
-					gaim_notify_user_info_add_pair(user_info, _("Idle"), gaim_str_seconds_to_string(jbir->idle_seconds));
+					char *idle = gaim_str_seconds_to_string(jbir->idle_seconds);
+					gaim_notify_user_info_add_pair(user_info, _("Idle"), idle);
+					g_free(idle);
 				}
 			}
 			if(jbr && jbr->client.name) {
@@ -729,6 +733,7 @@
 	while(l) {
 		if(!strcmp(id, l->data)) {
 			jbi->ids = g_slist_remove(jbi->ids, l->data);
+			g_free(l->data);			
 			return;
 		}
 		l = l->next;
--- a/libpurple/protocols/jabber/roster.c	Tue Feb 13 05:02:05 2007 +0000
+++ b/libpurple/protocols/jabber/roster.c	Tue Feb 13 22:19:26 2007 +0000
@@ -176,7 +176,7 @@
 			char *jid_norm;
 			const char *username;
 
-			jid_norm = g_strdup(jabber_normalize(js->gc->account, jid));
+			jid_norm = jabber_normalize(js->gc->account, jid);
 			username = gaim_account_get_username(js->gc->account);
 			me = g_utf8_collate(jid_norm,
 			                    jabber_normalize(js->gc->account,