Index: irc_im.c
===================================================================
--- irc_im.c	(revision 2dd23da38926e777c1dba707350b2afcf9421b25)
+++ irc_im.c	(revision 098a75b2b2f6a23b5740f6a2032d8a4c8d0d36b2)
@@ -235,5 +235,5 @@
 			} else {
 				/* Modules can swallow messages. */
-				return TRUE;
+				goto cleanup;
 			}
 		}
@@ -250,6 +250,7 @@
 	wrapped = word_wrap(msg, 425);
 	irc_send_msg(iu, "PRIVMSG", dst, wrapped, prefix);
-
 	g_free(wrapped);
+
+cleanup:
 	g_free(prefix);
 	g_free(msg);
@@ -291,4 +292,6 @@
 
 	irc_send_msg((irc_user_t *) bu->ui_data, "NOTICE", irc->user->nick, msg->str, NULL);
+
+	g_string_free(msg, TRUE);
 
 	return TRUE;
Index: lib/ssl_gnutls.c
===================================================================
--- lib/ssl_gnutls.c	(revision 2dd23da38926e777c1dba707350b2afcf9421b25)
+++ lib/ssl_gnutls.c	(revision 098a75b2b2f6a23b5740f6a2032d8a4c8d0d36b2)
@@ -124,4 +124,5 @@
 
 	if (conn->fd < 0) {
+		g_free(conn->hostname);
 		g_free(conn);
 		return NULL;
@@ -314,4 +315,5 @@
 	if (source == -1) {
 		conn->func(conn->data, 0, NULL, cond);
+		g_free(conn->hostname);
 		g_free(conn);
 		return FALSE;
@@ -355,8 +357,5 @@
 			conn->func(conn->data, 0, NULL, cond);
 
-			gnutls_deinit(conn->session);
-			closesocket(conn->fd);
-
-			g_free(conn);
+			ssl_disconnect(conn);
 		}
 	} else {
@@ -364,8 +363,5 @@
 			conn->func(conn->data, stver, NULL, cond);
 
-			gnutls_deinit(conn->session);
-			closesocket(conn->fd);
-
-			g_free(conn);
+			ssl_disconnect(conn);
 		} else {
 			/* For now we can't handle non-blocking perfectly everywhere... */
Index: otr.c
===================================================================
--- otr.c	(revision 2dd23da38926e777c1dba707350b2afcf9421b25)
+++ otr.c	(revision 098a75b2b2f6a23b5740f6a2032d8a4c8d0d36b2)
@@ -287,4 +287,5 @@
 void otr_irc_free(irc_t *irc)
 {
+	set_t *s;
 	otr_t *otr = irc->otr;
 
@@ -292,4 +293,8 @@
 	b_event_remove(otr->timer);
 	otrl_userstate_free(otr->us);
+
+	s = set_find(&irc->b->set, "otr_policy");
+	g_slist_free(s->eval_data);
+
 	if (otr->keygen) {
 		kill(otr->keygen, SIGTERM);
@@ -434,4 +439,8 @@
 	                                    ic->acc->user, ic->acc->prpl->name, iu->bu->handle, msg, &newmsg,
 	                                    &tlvs, NULL, NULL, NULL);
+
+	if (tlvs) {
+		otrl_tlv_free(tlvs);
+	}
 
 	if (ignore_msg) {
@@ -472,5 +481,5 @@
 		/* libotr wants us to replace our message */
 		/* NB: caller will free old msg */
-		msg = g_strdup(otrmsg);
+		msg = st ? NULL : g_strdup(otrmsg);
 		otrl_message_free(otrmsg);
 	}
@@ -1325,4 +1334,6 @@
 
 	log_message(LOGLVL_INFO, "otr: %s", msg);
+
+	g_free(msg);
 }
 
@@ -2075,4 +2086,2 @@
 	}
 }
-
-/* vim: set noet ts=4 sw=4: */
Index: protocols/jabber/jabber_util.c
===================================================================
--- protocols/jabber/jabber_util.c	(revision 2dd23da38926e777c1dba707350b2afcf9421b25)
+++ protocols/jabber/jabber_util.c	(revision 098a75b2b2f6a23b5740f6a2032d8a4c8d0d36b2)
@@ -566,4 +566,5 @@
 
 	if ((s = strchr(jid, '=')) == NULL) {
+		g_free(jid);
 		return NULL;
 	}
Index: protocols/msn/msn_util.c
===================================================================
--- protocols/msn/msn_util.c	(revision 2dd23da38926e777c1dba707350b2afcf9421b25)
+++ protocols/msn/msn_util.c	(revision 098a75b2b2f6a23b5740f6a2032d8a4c8d0d36b2)
@@ -174,11 +174,7 @@
 };
 
-static void msn_buddy_ask_yes(void *data)
+static void msn_buddy_ask_free(void *data)
 {
 	struct msn_buddy_ask_data *bla = data;
-
-	msn_buddy_list_add(bla->ic, MSN_BUDDY_AL, bla->handle, bla->realname, NULL);
-
-	imcb_ask_add(bla->ic, bla->handle, NULL);
 
 	g_free(bla->handle);
@@ -187,4 +183,15 @@
 }
 
+static void msn_buddy_ask_yes(void *data)
+{
+	struct msn_buddy_ask_data *bla = data;
+
+	msn_buddy_list_add(bla->ic, MSN_BUDDY_AL, bla->handle, bla->realname, NULL);
+
+	imcb_ask_add(bla->ic, bla->handle, NULL);
+
+	msn_buddy_ask_free(bla);
+}
+
 static void msn_buddy_ask_no(void *data)
 {
@@ -193,7 +200,5 @@
 	msn_buddy_list_add(bla->ic, MSN_BUDDY_BL, bla->handle, bla->realname, NULL);
 
-	g_free(bla->handle);
-	g_free(bla->realname);
-	g_free(bla);
+	msn_buddy_ask_free(bla);
 }
 
@@ -216,5 +221,6 @@
 	           "The user %s (%s) wants to add you to his/her buddy list.",
 	           bu->handle, bu->fullname);
-	imcb_ask(bu->ic, buf, bla, msn_buddy_ask_yes, msn_buddy_ask_no);
+
+	imcb_ask_with_free(bu->ic, buf, bla, msn_buddy_ask_yes, msn_buddy_ask_no, msn_buddy_ask_free);
 }
 
Index: protocols/nogaim.c
===================================================================
--- protocols/nogaim.c	(revision 2dd23da38926e777c1dba707350b2afcf9421b25)
+++ protocols/nogaim.c	(revision 098a75b2b2f6a23b5740f6a2032d8a4c8d0d36b2)
@@ -498,9 +498,7 @@
 };
 
-static void imcb_ask_auth_cb_no(void *data)
+static void imcb_ask_cb_free(void *data)
 {
 	struct imcb_ask_cb_data *cbd = data;
-
-	cbd->ic->acc->prpl->auth_deny(cbd->ic, cbd->handle);
 
 	g_free(cbd->handle);
@@ -508,4 +506,13 @@
 }
 
+static void imcb_ask_auth_cb_no(void *data)
+{
+	struct imcb_ask_cb_data *cbd = data;
+
+	cbd->ic->acc->prpl->auth_deny(cbd->ic, cbd->handle);
+
+	imcb_ask_cb_free(cbd);
+}
+
 static void imcb_ask_auth_cb_yes(void *data)
 {
@@ -514,6 +521,5 @@
 	cbd->ic->acc->prpl->auth_allow(cbd->ic, cbd->handle);
 
-	g_free(cbd->handle);
-	g_free(cbd);
+	imcb_ask_cb_free(cbd);
 }
 
@@ -535,12 +541,7 @@
 	data->handle = g_strdup(handle);
 	query_add((irc_t *) ic->bee->ui_data, ic, s,
-	          imcb_ask_auth_cb_yes, imcb_ask_auth_cb_no, g_free, data);
-}
-
-
-static void imcb_ask_add_cb_no(void *data)
-{
-	g_free(((struct imcb_ask_cb_data*) data)->handle);
-	g_free(data);
+	          imcb_ask_auth_cb_yes, imcb_ask_auth_cb_no, imcb_ask_cb_free, data);
+
+	g_free(s);
 }
 
@@ -551,10 +552,10 @@
 	cbd->ic->acc->prpl->add_buddy(cbd->ic, cbd->handle, NULL);
 
-	imcb_ask_add_cb_no(data);
+	imcb_ask_cb_free(data);
 }
 
 void imcb_ask_add(struct im_connection *ic, const char *handle, const char *realname)
 {
-	struct imcb_ask_cb_data *data = g_new0(struct imcb_ask_cb_data, 1);
+	struct imcb_ask_cb_data *data;
 	char *s;
 
@@ -564,4 +565,6 @@
 	}
 
+	data = g_new0(struct imcb_ask_cb_data, 1);
+
 	s = g_strdup_printf("The user %s is not in your buddy list yet. Do you want to add him/her now?", handle);
 
@@ -569,5 +572,7 @@
 	data->handle = g_strdup(handle);
 	query_add((irc_t *) ic->bee->ui_data, ic, s,
-	          imcb_ask_add_cb_yes, imcb_ask_add_cb_no, g_free, data);
+	          imcb_ask_add_cb_yes, imcb_ask_cb_free, imcb_ask_cb_free, data);
+
+	g_free(s);
 }
 
Index: storage_xml.c
===================================================================
--- storage_xml.c	(revision 2dd23da38926e777c1dba707350b2afcf9421b25)
+++ storage_xml.c	(revision 098a75b2b2f6a23b5740f6a2032d8a4c8d0d36b2)
@@ -128,4 +128,6 @@
 		}
 	} else {
+		g_free(pass_cr);
+		g_free(password);
 		return XT_ABORT;
 	}
