changeset 2806:535e3e2d230e HEAD

Don't access freed memory.
author Timo Sirainen <tss@iki.fi>
date Thu, 21 Oct 2004 23:58:23 +0300
parents 100ecc609dd1
children ad3fcccca2bb
files src/lib-storage/index/maildir/maildir-transaction.c
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-transaction.c	Thu Oct 21 23:47:36 2004 +0300
+++ b/src/lib-storage/index/maildir/maildir-transaction.c	Thu Oct 21 23:58:23 2004 +0300
@@ -20,6 +20,7 @@
 	struct maildir_transaction_context *t =
 		(struct maildir_transaction_context *)_t;
 	struct index_mailbox *ibox = t->ictx.ibox;
+	struct maildir_save_context *save_ctx;
 	int ret = 0;
 
 	if (t->save_ctx != NULL) {
@@ -33,13 +34,17 @@
 			ret = -1;
 	}
 
+	save_ctx = t->save_ctx;
+
 	if (index_transaction_commit(_t) < 0)
 		return -1;
 
-	if (t->save_ctx != NULL) {
+	/* transaction is destroyed. */
+
+	if (save_ctx != NULL) {
 		/* unlock uidlist file after writing to transaction log,
 		   to make sure we don't write uids in wrong order. */
-		maildir_transaction_save_commit_post(t->save_ctx);
+		maildir_transaction_save_commit_post(save_ctx);
 	}
 
 	return ret < 0 ? -1 : maildir_sync_last_commit(ibox);