changeset 4616:b0966236fda7 HEAD

Memory leak fixes
author Timo Sirainen <tss@iki.fi>
date Sun, 17 Sep 2006 21:34:15 +0300
parents c9bdfaa2e2cf
children 3c05b1f71ce6
files src/imap/imap-thread.c src/lib-index/mail-index-transaction.c src/lib-index/mail-index-view.c src/lib-index/mail-index.c
diffstat 4 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/imap-thread.c	Sun Sep 17 21:11:11 2006 +0300
+++ b/src/imap/imap-thread.c	Sun Sep 17 21:34:15 2006 +0300
@@ -1982,11 +1982,14 @@
 static int imap_thread_mailbox_close(struct mailbox *box)
 {
 	struct imap_thread_mailbox *tbox = IMAP_THREAD_CONTEXT(box);
+	int ret;
 
 	if (tbox->msgid_hash != NULL)
 		mail_hash_free(&tbox->msgid_hash);
 
-	return tbox->super.close(box);
+	ret = tbox->super.close(box);
+	i_free(tbox);
+	return ret;
 }
 
 static void imap_thread_hash_init(struct mailbox *box, bool create)
@@ -1997,6 +2000,8 @@
 
 	i_assert(tbox->msgid_hash == NULL);
 
+	box->v.close = imap_thread_mailbox_close;
+
 	tbox->msgid_hash =
 		mail_hash_open(ibox->index, ".thread", create ?
 			       MAIL_HASH_OPEN_FLAG_CREATE : 0,
@@ -2010,7 +2015,6 @@
 	mail_index_register_expunge_handler(ibox->index, ext_id,
 					    imap_thread_expunge_handler,
 					    tbox, TRUE);
-	box->v.close = imap_thread_mailbox_close;
 }
 
 static void imap_thread_mailbox_opened(struct mailbox *box)
--- a/src/lib-index/mail-index-transaction.c	Sun Sep 17 21:11:11 2006 +0300
+++ b/src/lib-index/mail-index-transaction.c	Sun Sep 17 21:34:15 2006 +0300
@@ -60,6 +60,7 @@
 	if (array_is_created(&t->ext_resets))
 		array_free(&t->ext_resets);
 
+	array_free(&t->mail_index_transaction_module_contexts);
 	mail_index_view_transaction_unref(t->view);
 	mail_index_view_close(&t->view);
 	i_free(t);
--- a/src/lib-index/mail-index-view.c	Sun Sep 17 21:11:11 2006 +0300
+++ b/src/lib-index/mail-index-view.c	Sun Sep 17 21:34:15 2006 +0300
@@ -13,7 +13,10 @@
 	dest->refcount = 1;
 	dest->v = src->v;
 	dest->index = src->index;
-	dest->log_view = mail_transaction_log_view_open(src->index->log);
+	if (src->log_view != NULL) {
+		dest->log_view =
+			mail_transaction_log_view_open(src->index->log);
+	}
 
 	dest->indexid = src->indexid;
 	dest->map = src->map;
--- a/src/lib-index/mail-index.c	Sun Sep 17 21:11:11 2006 +0300
+++ b/src/lib-index/mail-index.c	Sun Sep 17 21:34:15 2006 +0300
@@ -65,6 +65,7 @@
 
 	array_free(&index->sync_lost_handlers);
 	array_free(&index->keywords);
+	array_free(&index->mail_index_module_contexts);
 
 	i_free(index->error);
 	i_free(index->dir);
@@ -115,7 +116,7 @@
 	struct mail_index_registered_ext *rext;
 
 	rext = array_idx_modifiable(&index->extensions, ext_id);
-	i_assert(rext->expunge_handler == NULL);
+	i_assert(rext->expunge_handler == NULL || rext->expunge_handler == cb);
 
 	rext->expunge_handler = cb;
 	rext->expunge_context = context;