diff --git a/src/lib-sieve/plugins/metadata/tst-metadata.c b/src/lib-sieve/plugins/metadata/tst-metadata.c
index fe45fa9148762bbdec5ff48ea4d8b703149e9423..da659c606c1b50e6a4148f0f7f631f35b5e8f89a 100644
--- a/src/lib-sieve/plugins/metadata/tst-metadata.c
+++ b/src/lib-sieve/plugins/metadata/tst-metadata.c
@@ -274,6 +274,7 @@ static int tst_metadata_get_annotation
 		box = mailbox_alloc(ns->list, mailbox, 0);
 		imtrans = imap_metadata_transaction_begin(box);
 	} else {
+		box = NULL;
 		imtrans = imap_metadata_transaction_begin_server(user);
 	}