diff --git a/src/lib-sieve/sieve-actions.c b/src/lib-sieve/sieve-actions.c
index c1bdce0e24e11221a8d7f0418cddd27a98960a8c..8e71d4f68456711ceba12787d06d248f2dc3bdc1 100644
--- a/src/lib-sieve/sieve-actions.c
+++ b/src/lib-sieve/sieve-actions.c
@@ -186,7 +186,7 @@ static void act_store_get_storage_error
 }
 
 static struct mailbox *act_store_mailbox_open
-(const struct sieve_action_exec_env *aenv, const char *name,
+(const struct sieve_action_exec_env *aenv, const char **name,
 	struct mail_namespace **ns_r)
 {
 	struct mail_storage **storage = &(aenv->exec_status->last_storage);
@@ -195,7 +195,7 @@ static struct mailbox *act_store_mailbox_open
 		MAILBOX_FLAG_POST_SESSION;
 	struct mailbox *box;
 	enum mail_error error;
-	const char *folder = name;
+	const char *folder = *name;
 
 	if (strcasecmp(folder, "INBOX") == 0) {
 		/* Deliveries to INBOX must always succeed, regardless of ACLs */
@@ -212,7 +212,7 @@ static struct mailbox *act_store_mailbox_open
 		/* delivering to a namespace prefix means we actually want to
 		 * deliver to the INBOX instead
 		 */
-		folder = "INBOX";
+		folder = *name = "INBOX";
 		flags |= MAILBOX_FLAG_IGNORE_ACLS;
 
 		*ns_r = mail_namespace_find(aenv->scriptenv->namespaces, &folder);
@@ -286,7 +286,7 @@ static bool act_store_start
 	 * to NULL. This implementation will then skip actually storing the message.
 	 */
 	if ( aenv->scriptenv->namespaces != NULL ) {
-		box = act_store_mailbox_open(aenv, ctx->folder, &ns);
+		box = act_store_mailbox_open(aenv, &ctx->folder, &ns);
 	}
 				
 	/* Create transaction context */