changeset 10519:bec9130b24d2

[gaim-migrate @ 11833] Leak fixes, round #2. And some minor MSN tweaks suggested by Felipe. committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Mon, 17 Jan 2005 00:33:30 +0000
parents 8ae540ad42e7
children 976c7b186789
files plugins/ssl/ssl-nss.c plugins/tcl/tcl_signals.c src/gtkaccount.c src/protocols/msn/msn.h src/protocols/msn/nexus.c src/protocols/msn/notification.c src/protocols/msn/session.c src/protocols/msn/session.h src/protocols/msn/slp.c src/protocols/silc/chat.c src/status.c
diffstat 11 files changed, 85 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/ssl/ssl-nss.c	Sat Jan 15 16:53:55 2005 +0000
+++ b/plugins/ssl/ssl-nss.c	Mon Jan 17 00:33:30 2005 +0000
@@ -57,18 +57,18 @@
 static void
 ssl_nss_init_nss(void)
 {
+	char *lib;
 	PR_Init(PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1);
 	NSS_NoDB_Init(NULL);
 
 	/* TODO: Fix this so autoconf does the work trying to find this lib. */
-	SECMOD_AddNewModule("Builtins",
 #ifndef _WIN32
-                            g_strdup(BR_LIBDIR("/libnssckbi.so")),
-			    /* this might leak, and looks wrong in general */
+	lib = g_strdup(BR_LIBDIR("/libnssckbi.so"));
 #else
-                            "nssckbi.dll",
+	lib = g_strdup("nssckbi.dll");
 #endif
-                            0, 0);
+	SECMOD_AddNewModule("Builtins", lib, 0, 0);
+	g_free(lib);
 	NSS_SetDomesticPolicy();
 
 	_identity = PR_GetUniqueIdentity("Gaim");
--- a/plugins/tcl/tcl_signals.c	Sat Jan 15 16:53:55 2005 +0000
+++ b/plugins/tcl/tcl_signals.c	Mon Jan 17 00:33:30 2005 +0000
@@ -43,12 +43,17 @@
 
 void tcl_signal_handler_free(struct tcl_signal_handler *handler)
 {
+	int i;
+
 	if (handler == NULL)
 		return;
 
 	g_free(handler->signal);
-        if (handler->argnames != NULL)
+    if (handler->argnames != NULL) {
+		for (i = 0; i < handler->nnames; i++)
+			g_free(handler->argnames[i]);
 		g_free(handler->argnames);
+	}
 	Tcl_DecrRefCount(handler->proc);
 	g_free(handler);
 }
--- a/src/gtkaccount.c	Sat Jan 15 16:53:55 2005 +0000
+++ b/src/gtkaccount.c	Mon Jan 17 00:33:30 2005 +0000
@@ -244,7 +244,7 @@
 static void
 icon_filesel_choose_cb(GtkWidget *widget, gint response, AccountPrefsDialog *dialog)
 {
-	const char *filename;
+	char *filename;
 
 	if (response != GTK_RESPONSE_ACCEPT) {
 		if (response == GTK_RESPONSE_CANCEL)
@@ -258,15 +258,16 @@
 static void
 icon_filesel_choose_cb(GtkWidget *w, AccountPrefsDialog *dialog)
 {
-	const char *filename;
-
-	filename = gtk_file_selection_get_filename(
-			GTK_FILE_SELECTION(dialog->icon_filesel));
+	char *filename;
+
+	filename = g_strdup(gtk_file_selection_get_filename(
+			GTK_FILE_SELECTION(dialog->icon_filesel)));
 
 	/* If they typed in a directory, change there */
 	if (gaim_gtk_check_if_dir(filename,
 			GTK_FILE_SELECTION(dialog->icon_filesel)))
 	{
+		g_free(filename);
 		return;
 	}
 #endif /* FILECHOOSER */
@@ -279,6 +280,7 @@
 
 	gtk_widget_destroy(dialog->icon_filesel);
 	dialog->icon_filesel = NULL;
+	g_free(filename);
  }
 
 static void
@@ -292,18 +294,21 @@
 	int height, width;
 	char *basename, *markup, *size;
 	struct stat st;
-	const char *filename;
+	char *filename;
 
 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */
 	filename = gtk_file_chooser_get_preview_filename(
 					GTK_FILE_CHOOSER(dialog->icon_filesel));
 #else /* FILECHOOSER */
-	filename = gtk_file_selection_get_filename(
-		GTK_FILE_SELECTION(dialog->icon_filesel));
+	filename = g_strdup(gtk_file_selection_get_filename(
+		GTK_FILE_SELECTION(dialog->icon_filesel)));
 #endif /* FILECHOOSER */
 
 	if (!filename || stat(filename, &st))
+	{
+		g_free(filename);
 		return;
+	}
 
 	pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
 	if (!pixbuf) {
@@ -313,6 +318,7 @@
 		gtk_file_chooser_set_preview_widget_active(
 					GTK_FILE_CHOOSER(dialog->icon_filesel), FALSE);
 #endif /* FILECHOOSER */
+		g_free(filename);
 		return;
 	}
 
@@ -336,6 +342,7 @@
 
 	g_object_unref(G_OBJECT(pixbuf));
 	g_object_unref(G_OBJECT(scale));
+	g_free(filename);
 	g_free(basename);
 	g_free(size);
 	g_free(markup);
@@ -535,6 +542,8 @@
 		   prpl_info->icon_spec.max_width >= width &&
 		   prpl_info->icon_spec.min_height <= height &&
 		   prpl_info->icon_spec.max_height >= height))) {                                  /* The icon is the correct size */
+		g_strfreev(prpl_formats);
+		g_strfreev(pixbuf_formats);
 #endif
 		return g_strdup(path);
 #if GTK_CHECK_VERSION(2,2,0)
@@ -546,6 +555,7 @@
 		const char *dirname = gaim_buddy_icons_get_cache_dir();
 		char *filename = g_build_filename(dirname, random, NULL);
 		pixbuf = gdk_pixbuf_new_from_file(path, &error);
+		g_strfreev(pixbuf_formats);
 		if (!error && (prpl_info->icon_spec.scale_rules & GAIM_ICON_SCALE_SEND) &&
 			(width < prpl_info->icon_spec.min_width ||
 			 width > prpl_info->icon_spec.max_width ||
@@ -574,6 +584,7 @@
 			g_free(random);
 			gaim_debug_error("buddyicon", "Could not open icon for conversion: %s\n", error->message);
 			g_error_free(error);
+			g_strfreev(prpl_formats);
 			return NULL;
 		}
 
@@ -584,6 +595,7 @@
 				gaim_debug_error("buddyicon",
 								 "Unable to create directory %s: %s\n",
 								 dirname, strerror(errno));
+				g_strfreev(prpl_formats);
 				return NULL;
 			}
 		}
@@ -595,6 +607,7 @@
 			if (gdk_pixbuf_save (pixbuf, filename, prpl_formats[i], &error, NULL) == TRUE)
 					break;
 		}
+		g_strfreev(prpl_formats);
 		if (!error) {
 			g_free(random);
 			g_object_unref(G_OBJECT(pixbuf));
@@ -1285,6 +1298,9 @@
 	if (dialog->protocol_id != NULL)
 		g_free(dialog->protocol_id);
 
+	if (dialog->icon_path != NULL)
+		g_free(dialog->icon_path);
+
 	if (dialog->icon_filesel)
 		gtk_widget_destroy(dialog->icon_filesel);
 
--- a/src/protocols/msn/msn.h	Sat Jan 15 16:53:55 2005 +0000
+++ b/src/protocols/msn/msn.h	Mon Jan 17 00:33:30 2005 +0000
@@ -24,6 +24,14 @@
 #ifndef _MSN_H_
 #define _MSN_H_
 
+/* #define MSN_DEBUG_MSG 1 */
+/* #define MSN_DEBUG_SLPMSG 1 */
+/* #define MSN_DEBUG_HTTP 1 */
+
+/* #define MSN_DEBUG_SLP 1 */
+/* #define MSN_DEBUG_SLP_VERBOSE 1 */
+/* #define MSN_DEBUG_SLP_FILES 1 */
+
 #include "internal.h"
 
 #include "account.h"
@@ -45,14 +53,6 @@
 
 #include "ft.h"
 
-/* #define MSN_DEBUG_MSG 1 */
-/* #define MSN_DEBUG_SLPMSG 1 */
-/* #define MSN_DEBUG_HTTP 1 */
-
-/* #define MSN_DEBUG_SLP 1 */
-/* #define MSN_DEBUG_SLP_VERBOSE 1 */
-/* #define MSN_DEBUG_SLP_FILES 1 */
-
 #define MSN_BUF_LEN 8192
 
 #define USEROPT_MSNSERVER 3
--- a/src/protocols/msn/nexus.c	Sat Jan 15 16:53:55 2005 +0000
+++ b/src/protocols/msn/nexus.c	Mon Jan 17 00:33:30 2005 +0000
@@ -132,8 +132,7 @@
 	session = nexus->session;
 	g_return_if_fail(session != NULL);
 
-	if (!session->logged_in)
-		msn_session_set_login_step(session, MSN_LOGIN_STEP_GET_COOKIE);
+	msn_session_set_login_step(session, MSN_LOGIN_STEP_GET_COOKIE);
 
 	username =
 		g_strdup(gaim_url_encode(gaim_account_get_username(session->account)));
@@ -313,8 +312,7 @@
 	session = nexus->session;
 	g_return_if_fail(session != NULL);
 
-	if (!session->logged_in)
-		msn_session_set_login_step(session, MSN_LOGIN_STEP_AUTH);
+	msn_session_set_login_step(session, MSN_LOGIN_STEP_AUTH);
 
 	request_str = g_strdup_printf("GET /rdr/pprdr.asp\r\n\r\n");
 
--- a/src/protocols/msn/notification.c	Sat Jan 15 16:53:55 2005 +0000
+++ b/src/protocols/msn/notification.c	Mon Jan 17 00:33:30 2005 +0000
@@ -111,13 +111,10 @@
 
 	vers = g_strjoinv(" ", a);
 
-	if (!session->logged_in)
-	{
-		if (session->login_step == MSN_LOGIN_STEP_START)
-			msn_session_set_login_step(session, MSN_LOGIN_STEP_HANDSHAKE);
-		else
-			msn_session_set_login_step(session, MSN_LOGIN_STEP_HANDSHAKE2);
-	}
+	if (session->login_step == MSN_LOGIN_STEP_START)
+		msn_session_set_login_step(session, MSN_LOGIN_STEP_HANDSHAKE);
+	else
+		msn_session_set_login_step(session, MSN_LOGIN_STEP_HANDSHAKE2);
 
 	msn_cmdproc_send(cmdproc, "VER", "%s", vers);
 
@@ -206,8 +203,7 @@
 
 	cmdproc = session->notification->cmdproc;
 
-	if (!session->logged_in)
-		msn_session_set_login_step(session, MSN_LOGIN_STEP_AUTH_END);
+	msn_session_set_login_step(session, MSN_LOGIN_STEP_AUTH_END);
 
 	msn_cmdproc_send(cmdproc, "USR", "TWN S %s", login_params);
 }
@@ -241,8 +237,7 @@
 
 		gaim_connection_set_display_name(gc, friendly);
 
-		if (!session->logged_in)
-			msn_session_set_login_step(session, MSN_LOGIN_STEP_SYN);
+		msn_session_set_login_step(session, MSN_LOGIN_STEP_SYN);
 
 		msn_cmdproc_send(cmdproc, "SYN", "%s", "0");
 	}
@@ -267,8 +262,7 @@
 
 		g_strfreev(elems);
 
-		if (!session->logged_in)
-			msn_session_set_login_step(session, MSN_LOGIN_STEP_AUTH_START);
+		msn_session_set_login_step(session, MSN_LOGIN_STEP_AUTH_START);
 
 		msn_nexus_connect(session->nexus);
 	}
@@ -299,7 +293,7 @@
 
 	if (!protocol_supported)
 	{
-		msn_session_set_error(session, MSN_ERROR_UNSUPORTED_PROTOCOL,
+		msn_session_set_error(session, MSN_ERROR_UNSUPPORTED_PROTOCOL,
 							  NULL);
 		return;
 	}
@@ -1012,8 +1006,7 @@
 
 		session = cmdproc->session;
 
-		if (!session->logged_in)
-			msn_session_set_login_step(session, MSN_LOGIN_STEP_TRANSFER);
+		msn_session_set_login_step(session, MSN_LOGIN_STEP_TRANSFER);
 
 		msn_notification_connect(session->notification, host, port);
 	}
--- a/src/protocols/msn/session.c	Sat Jan 15 16:53:55 2005 +0000
+++ b/src/protocols/msn/session.c	Mon Jan 17 00:33:30 2005 +0000
@@ -289,7 +289,7 @@
 		case MSN_ERROR_SERVCONN:
 			msg = g_strdup(info);
 			break;
-		case MSN_ERROR_UNSUPORTED_PROTOCOL:
+		case MSN_ERROR_UNSUPPORTED_PROTOCOL:
 			msg = g_strdup(_("Our protocol is not supported by the "
 							 "server."));
 			break;
@@ -348,6 +348,17 @@
 {
 	GaimConnection *gc;
 
+	/* Prevent the connection progress going backwards, eg. if we get
+	 * transferred several times during login */
+	if (session->login_step >= step)
+		return;
+
+	/* If we're already logged in, we're probably here because of a
+	 * mid-session XFR from the notification server, so we don't want to
+	 * popup the connection progress dialog */
+	if (session->logged_in)
+		return;
+
 	gc = session->account->gc;
 
 	session->login_step = step;
--- a/src/protocols/msn/session.h	Sat Jan 15 16:53:55 2005 +0000
+++ b/src/protocols/msn/session.h	Mon Jan 17 00:33:30 2005 +0000
@@ -46,7 +46,7 @@
 typedef enum
 {
 	MSN_ERROR_SERVCONN,
-	MSN_ERROR_UNSUPORTED_PROTOCOL,
+	MSN_ERROR_UNSUPPORTED_PROTOCOL,
 	MSN_ERROR_HTTP_MALFORMED,
 	MSN_ERROR_AUTH,
 	MSN_ERROR_BAD_BLIST,
--- a/src/protocols/msn/slp.c	Sat Jan 15 16:53:55 2005 +0000
+++ b/src/protocols/msn/slp.c	Mon Jan 17 00:33:30 2005 +0000
@@ -290,6 +290,8 @@
 			g_return_if_reached();
 		}
 
+		msn_object_destroy(obj);
+
 		slpsession = msn_slplink_find_slp_session(slplink,
 												  slpcall->session_id);
 
@@ -645,6 +647,7 @@
 
 		got_invite(slpcall, branch, content_type, content);
 
+		g_free(branch);
 		g_free(content_type);
 		g_free(content);
 	}
@@ -1005,6 +1008,7 @@
 
 		/* TODO: I think we need better buddy icon core functions. */
 		gaim_buddy_icons_set_for_user(account, user->passport, (void *)data, len);
+		g_free(data);
 
 		sl = gaim_find_buddies(account, user->passport);
 
--- a/src/protocols/silc/chat.c	Sat Jan 15 16:53:55 2005 +0000
+++ b/src/protocols/silc/chat.c	Mon Jan 17 00:33:30 2005 +0000
@@ -31,6 +31,7 @@
 	pce = g_new0(struct proto_chat_entry, 1);
 	pce->label = _("_Channel:");
 	pce->identifier = "channel";
+	pce->required = TRUE;
 	ci = g_list_append(ci, pce);
 
 	pce = g_new0(struct proto_chat_entry, 1);
--- a/src/status.c	Sat Jan 15 16:53:55 2005 +0000
+++ b/src/status.c	Mon Jan 17 00:33:30 2005 +0000
@@ -1663,7 +1663,7 @@
 	primitive_scores[index] = GPOINTER_TO_INT(value);
 }
 
-guint
+static guint
 gaim_buddy_presences_hash(gconstpointer key)
 {
 	const GaimStatusBuddyKey *me = key;
@@ -1677,7 +1677,7 @@
 	return ret;
 }
 
-gboolean
+static gboolean
 gaim_buddy_presences_equal(gconstpointer a, gconstpointer b)
 {
 	GaimStatusBuddyKey *key_a = (GaimStatusBuddyKey *)a;
@@ -1690,6 +1690,14 @@
 		return FALSE;
 }
 
+static void
+gaim_buddy_presences_key_free(gpointer a)
+{
+	GaimStatusBuddyKey *key = (GaimStatusBuddyKey *)a;
+	g_free(key->name);
+	g_free(key);
+}
+
 void *
 gaim_status_get_handle(void) {
 	static int handle;
@@ -1737,8 +1745,9 @@
 			score_pref_changed_cb,
 			GINT_TO_POINTER(SCORE_IDLE));
 
-	buddy_presences = g_hash_table_new(gaim_buddy_presences_hash,
-									   gaim_buddy_presences_equal);
+	buddy_presences = g_hash_table_new_full(gaim_buddy_presences_hash,
+											gaim_buddy_presences_equal,
+											gaim_buddy_presences_key_free, NULL);
 }
 
 void