changeset 27799:da33da2e1a1e

Fix a bunch of memory leaks reported by Josh Mueller. Refs #9822.
author Paul Aurich <paul@darkrain42.org>
date Sun, 02 Aug 2009 05:04:41 +0000
parents c91832e94473
children deecc1d663c4
files ChangeLog libpurple/cipher.c libpurple/desktopitem.c libpurple/ft.c libpurple/protocols/gg/lib/libgadu.c libpurple/protocols/jabber/google.c libpurple/protocols/msn/directconn.c libpurple/protocols/msnp9/directconn.c libpurple/protocols/yahoo/libymsg.c libpurple/protocols/yahoo/yahoo_filexfer.c pidgin/gtkprefs.c pidgin/plugins/crazychat/glm.c
diffstat 12 files changed, 24 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Aug 02 04:33:26 2009 +0000
+++ b/ChangeLog	Sun Aug 02 05:04:41 2009 +0000
@@ -44,6 +44,7 @@
 	* Install scalable versions of the main Pidgin icon, the protocol icons,
 	  the dialog icons, and the Buddy List emblems.
 	* Build properly on Hurd.  (Marc Dequènes)
+	* Various memory leaks fixed as reported by Josh Mueller.
 
 	AIM and ICQ:
 	* Preliminary support for a new authentication scheme called
--- a/libpurple/cipher.c	Sun Aug 02 04:33:26 2009 +0000
+++ b/libpurple/cipher.c	Sun Aug 02 05:04:41 2009 +0000
@@ -2727,8 +2727,6 @@
 
 		cipher = PURPLE_CIPHER(l->data);
 		purple_ciphers_unregister_cipher(cipher);
-
-		ciphers = g_list_remove(ciphers, cipher);
 	}
 
 	g_list_free(ciphers);
--- a/libpurple/desktopitem.c	Sun Aug 02 04:33:26 2009 +0000
+++ b/libpurple/desktopitem.c	Sun Aug 02 05:04:41 2009 +0000
@@ -831,11 +831,10 @@
 static char *
 try_english_key (PurpleDesktopItem *item, const char *key)
 {
-	char *str;
+	char *str = NULL;
 	char *locales[] = { "en_US", "en_GB", "en_AU", "en", NULL };
 	int i;
 
-	str = NULL;
 	for (i = 0; locales[i] != NULL && str == NULL; i++) {
 		str = g_strdup (lookup_locale (item, key, locales[i]));
 	}
--- a/libpurple/ft.c	Sun Aug 02 04:33:26 2009 +0000
+++ b/libpurple/ft.c	Sun Aug 02 05:04:41 2009 +0000
@@ -953,15 +953,15 @@
 			if (wc != r) {
 				purple_debug_error("filetransfer", "Unable to write whole buffer.\n");
 				purple_xfer_cancel_local(xfer);
+				g_free(buffer);
 				return;
 			}
 		} else if(r < 0) {
 			purple_xfer_cancel_remote(xfer);
+			g_free(buffer);
 			return;
 		}
-	}
-
-	if (condition & PURPLE_INPUT_WRITE) {
+	} else if (condition & PURPLE_INPUT_WRITE) {
 		size_t result;
 		size_t s = MIN(purple_xfer_get_bytes_remaining(xfer), xfer->current_buffer_size);
 
--- a/libpurple/protocols/gg/lib/libgadu.c	Sun Aug 02 04:33:26 2009 +0000
+++ b/libpurple/protocols/gg/lib/libgadu.c	Sun Aug 02 05:04:41 2009 +0000
@@ -790,6 +790,7 @@
 		gg_debug(GG_DEBUG_MISC, "// gg_recv_packet() body recv(%d,%p,%d) = %d\n", sess->fd, buf + sizeof(h) + offset, size, ret);
 		if (!ret) {
 			gg_debug(GG_DEBUG_MISC, "// gg_recv_packet() body recv() failed: connection broken\n");
+			free(buf);
 			errno = ECONNRESET;
 			return NULL;
 		}
--- a/libpurple/protocols/jabber/google.c	Sun Aug 02 04:33:26 2009 +0000
+++ b/libpurple/protocols/jabber/google.c	Sun Aug 02 05:04:41 2009 +0000
@@ -430,7 +430,7 @@
 	return (session->media != NULL) ? TRUE : FALSE;
 }
 
-static void
+static gboolean
 google_session_handle_initiate(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id)
 {
 	JabberIq *result;
@@ -443,7 +443,7 @@
 
 	if (session->state != UNINIT) {
 		purple_debug_error("jabber", "Received initiate for active session.\n");
-		return;
+		return FALSE;
 	}
 
 	desc_element = xmlnode_get_child(sess, "description");
@@ -456,7 +456,7 @@
 	else {
 		purple_debug_error("jabber", "Received initiate with "
 				"invalid namespace %s.\n", xmlns);
-		return;
+		return FALSE;
 	}
 
 	session->media = purple_media_manager_create_media(
@@ -480,7 +480,7 @@
 				PURPLE_MEDIA_INFO_HANGUP, NULL, NULL, TRUE);
 		google_session_send_terminate(session);
 		g_free(params);
-		return;
+		return FALSE;
 	}
 
 	g_free(params);
@@ -551,6 +551,8 @@
 	jabber_iq_set_id(result, iq_id);
 	xmlnode_set_attrib(result->node, "to", session->remote_jid);
 	jabber_iq_send(result);
+
+	return TRUE;
 }
 
 static void
@@ -776,7 +778,8 @@
 	session->js = js;
 	session->remote_jid = g_strdup(session->id.initiator);
 
-	google_session_parse_iq(js, session, session_node, iq_id);
+	if (!google_session_handle_initiate(js, session, session_node, iq_id))
+		google_session_destroy(session);
 }
 #endif /* USE_VV */
 
--- a/libpurple/protocols/msn/directconn.c	Sun Aug 02 04:33:26 2009 +0000
+++ b/libpurple/protocols/msn/directconn.c	Sun Aug 02 05:04:41 2009 +0000
@@ -351,6 +351,8 @@
 
 		msn_directconn_destroy(directconn);
 	}
+
+	g_free(body);
 }
 
 static void
--- a/libpurple/protocols/msnp9/directconn.c	Sun Aug 02 04:33:26 2009 +0000
+++ b/libpurple/protocols/msnp9/directconn.c	Sun Aug 02 05:04:41 2009 +0000
@@ -355,6 +355,8 @@
 
 		msn_directconn_destroy(directconn);
 	}
+
+	g_free(body);
 }
 
 static void
--- a/libpurple/protocols/yahoo/libymsg.c	Sun Aug 02 04:33:26 2009 +0000
+++ b/libpurple/protocols/yahoo/libymsg.c	Sun Aug 02 05:04:41 2009 +0000
@@ -1830,6 +1830,7 @@
 			g_free(error_reason);
 			g_free(auth_data->seed);
 			g_free(auth_data);
+			g_free(token);
 		}
 		else {
 			/* OK to login, correct information provided */
--- a/libpurple/protocols/yahoo/yahoo_filexfer.c	Sun Aug 02 04:33:26 2009 +0000
+++ b/libpurple/protocols/yahoo/yahoo_filexfer.c	Sun Aug 02 05:04:41 2009 +0000
@@ -1593,7 +1593,7 @@
 	char *service = NULL;
 	char *filename = NULL;
 	char *xfer_peer_idstring = NULL;
-	char *utf8_filename
+	char *utf8_filename;
 	unsigned long filesize = 0L;
 	GSList *l;
 	GSList *filename_list = NULL;
--- a/pidgin/gtkprefs.c	Sun Aug 02 04:33:26 2009 +0000
+++ b/pidgin/gtkprefs.c	Sun Aug 02 05:04:41 2009 +0000
@@ -698,7 +698,8 @@
 		g_free(original_name);
 		g_free(info);
 		return;
-	} else g_free(info);
+	} else
+		g_free(info);
 
 	is_archive = !g_ascii_strcasecmp(tail, ".gz") || !g_ascii_strcasecmp(tail, ".tgz");
 
@@ -1032,8 +1033,6 @@
 	info->original_name = NULL;
 
 	theme_install_theme(theme_file_name, info);
-
-	g_free(info);
 }
 
 static void
--- a/pidgin/plugins/crazychat/glm.c	Sun Aug 02 04:33:26 2009 +0000
+++ b/pidgin/plugins/crazychat/glm.c	Sun Aug 02 05:04:41 2009 +0000
@@ -543,6 +543,8 @@
     fprintf(file, "Ns %f\n", material->shininess / 128.0 * 1000.0);
     fprintf(file, "\n");
   }
+
+  fclose(file);
 }