diff --git a/src/lib-sieve/plugins/mailbox/tag-mailbox-create.c b/src/lib-sieve/plugins/mailbox/tag-mailbox-create.c
index c9bebc51aec50d76e3700926798f74d3bee433f5..61766b72851112050d16309fe9aef41c647dc901 100644
--- a/src/lib-sieve/plugins/mailbox/tag-mailbox-create.c
+++ b/src/lib-sieve/plugins/mailbox/tag-mailbox-create.c
@@ -124,12 +124,13 @@ seff_mailbox_create_pre_execute(
 	struct act_store_transaction *trans =
 		(struct act_store_transaction *)tr_context;
 	const struct sieve_execute_env *eenv = aenv->exec_env;
+	struct mailbox *box = trans->box;
 
 	/* Check whether creation is necessary */
-	if (trans->box == NULL || trans->disabled)
+	if (box == NULL || trans->disabled)
 		return SIEVE_EXEC_OK;
 
-	eenv->exec_status->last_storage = mailbox_get_storage(trans->box);
+	eenv->exec_status->last_storage = mailbox_get_storage(box);
 
 	/* Check whether creation has a chance of working */
 	switch (trans->error_code) {
@@ -147,7 +148,7 @@ seff_mailbox_create_pre_execute(
 	trans->error_code = MAIL_ERROR_NONE;
 
 	/* Create mailbox */
-	if (mailbox_create(trans->box, NULL, FALSE) < 0) {
+	if (mailbox_create(box, NULL, FALSE) < 0) {
 		sieve_act_store_get_storage_error(aenv, trans);
 		if (trans->error_code == MAIL_ERROR_EXISTS) {
 			trans->error = NULL;
@@ -161,12 +162,12 @@ seff_mailbox_create_pre_execute(
 	/* Subscribe to it if necessary */
 	if (eenv->scriptenv->mailbox_autosubscribe) {
 		(void)mailbox_list_set_subscribed(
-			mailbox_get_namespace(trans->box)->list,
-			mailbox_get_name(trans->box), TRUE);
+			mailbox_get_namespace(box)->list,
+			mailbox_get_name(box), TRUE);
 	}
 
 	/* Try opening again */
-	if (mailbox_open(trans->box) < 0) {
+	if (mailbox_open(box) < 0) {
 		/* Failed definitively */
 		sieve_act_store_get_storage_error(aenv, trans);
 		return (trans->error_code == MAIL_ERROR_TEMP ?