# HG changeset patch # User Timo Sirainen # Date 1480502085 -7200 # Node ID d29e14e83679b5f07ed609d2acbbb63aeb4da31a # Parent e0aad1bacb5f95470a09811777b99b1d56ac4ff4 lib-storage: If mailbox_create() fails, don't leave box in partially opened state. For example with sdbox it may have opened the indexes, but not set mailbox's GUID. A following MAILBOX_METADATA_GUID would then assert-crash because GUID is empty. diff -r e0aad1bacb5f -r d29e14e83679 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Wed Nov 30 00:28:08 2016 +0200 +++ b/src/lib-storage/mail-storage.c Wed Nov 30 12:34:45 2016 +0200 @@ -1330,6 +1330,13 @@ box->creating = FALSE; if (ret == 0) box->list->guid_cache_updated = TRUE; + else if (box->opened) { + /* Creation failed after (partially) opening the mailbox. + It may not be in a valid state, so close it. */ + mail_storage_last_error_push(box->storage); + mailbox_close(box); + mail_storage_last_error_pop(box->storage); + } return ret; }