changeset 13833:571aebbe5ec6

[gaim-migrate @ 16282] SF Patch #1502594 from Yosef Radchenko "Patches three instances of memory leaks with gaim_accounts_get_all_active" committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Mon, 19 Jun 2006 05:39:30 +0000
parents d1fdde7cfc0a
children 378bba5011e7
files plugins/idle.c plugins/perl/common/Account.xs src/gtkmain.c
diffstat 3 files changed, 17 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/idle.c	Mon Jun 19 05:17:54 2006 +0000
+++ b/plugins/idle.c	Mon Jun 19 05:39:30 2006 +0000
@@ -102,12 +102,13 @@
 idle_all_action_ok(void *ignored, GaimRequestFields *fields)
 {
 	GaimAccount *acct = NULL;
-	GList *l = gaim_accounts_get_all_active();
+	GList *list, *iter;
 	int tm = gaim_request_fields_get_integer(fields, "mins");
 	const char *prpl_id = NULL;
 
-	for(; l; l = l->next) {
-		acct = (GaimAccount *)(l->data);
+	list = gaim_accounts_get_all_active();
+	for(iter = list; iter; iter = iter->next) {
+		acct = (GaimAccount *)(iter->data);
 
 		if(acct)
 			prpl_id = gaim_account_get_protocol_id(acct);
@@ -122,6 +123,8 @@
 				idled_accts = g_list_append(idled_accts, acct);
 		}
 	}
+
+	g_list_free(list);
 }
 
 static void
--- a/plugins/perl/common/Account.xs	Mon Jun 19 05:17:54 2006 +0000
+++ b/plugins/perl/common/Account.xs	Mon Jun 19 05:39:30 2006 +0000
@@ -286,11 +286,13 @@
 void
 gaim_accounts_get_all_active()
 PREINIT:
-	GList *l;
+	GList *list, *iter;
 PPCODE:
-	for (l = gaim_accounts_get_all_active(); l != NULL; l = l->next) {
-		XPUSHs(sv_2mortal(gaim_perl_bless_object(l->data, "Gaim::Account")));
+	list = gaim_accounts_get_all_active();
+	for (iter = gaim_accounts_get_all_active(); iter != NULL; iter = iter->next) {
+		XPUSHs(sv_2mortal(gaim_perl_bless_object(iter->data, "Gaim::Account")));
 	}
+	g_list_free(list);
 
 Gaim::Account
 gaim_accounts_find(name, protocol)
--- a/src/gtkmain.c	Mon Jun 19 05:17:54 2006 +0000
+++ b/src/gtkmain.c	Mon Jun 19 05:39:30 2006 +0000
@@ -432,6 +432,7 @@
 	char *opt_session_arg = NULL;
 	int dologin_ret = -1;
 	char *search_path;
+	GList *accounts;
 #ifdef HAVE_SIGNAL_H
 	int sig_indx;	/* for setting up signal catching */
 	sigset_t sigset;
@@ -752,10 +753,14 @@
 		gaim_accounts_restore_current_statuses();
 	}
 
-	if (gaim_accounts_get_all_active() == NULL)
+	if ((accounts = gaim_accounts_get_all_active()) == NULL)
 	{
 		gaim_gtk_accounts_window_show();
 	}
+	else
+	{
+		g_list_free(accounts);
+	}
 
 #ifdef HAVE_STARTUP_NOTIFICATION
 	startup_notification_complete();