changeset 13458:e60a3b29117c

imapc: Crashfix when sometimes closing mailbox.
author Timo Sirainen <tss@iki.fi>
date Tue, 13 Sep 2011 10:32:11 +0300
parents 835891cf2eef
children f3eb6cc4b627
files src/lib-storage/index/imapc/imapc-client.c
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/imapc/imapc-client.c	Mon Sep 12 18:29:17 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-client.c	Tue Sep 13 10:32:11 2011 +0300
@@ -238,8 +238,6 @@
 	struct imapc_client_mailbox *box = *_box;
 	struct imapc_client_connection *const *connp;
 
-	*_box = NULL;
-
 	array_foreach(&box->client->conns, connp) {
 		if ((*connp)->box == box) {
 			(*connp)->box = NULL;
@@ -251,6 +249,10 @@
 		imapc_connection_unselect(box);
 	imapc_msgmap_deinit(&box->msgmap);
 	i_free(box);
+
+	/* set this only after unselect, which may cancel some commands that
+	   reference this box */
+	*_box = NULL;
 }
 
 static void imapc_client_mailbox_cmd_cb(const struct imapc_command_reply *reply,