Skip to content

Commit

Permalink
lib-storage: If mailbox_create() fails, don't leave box in partially …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
sirainen committed Dec 3, 2016
1 parent 81cbf87 commit d3426e9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lib-storage/mail-storage.c
Expand Up @@ -1330,6 +1330,13 @@ int mailbox_create(struct mailbox *box, const struct mailbox_update *update,
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;
}

Expand Down

0 comments on commit d3426e9

Please sign in to comment.