From: Aki Tuomi Date: Tue, 8 Nov 2016 18:41:15 +0000 (+0200) Subject: imap: Free box on error X-Git-Tag: 2.2.27~188 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7dc4e79d850b1ba4b5056f198921dd773fa77afb;p=thirdparty%2Fdovecot%2Fcore.git imap: Free box on error Otherwise the box wil leak as it is not assigned anywhere and can cause crash on imap exit due to stats plugin timeout leak. --- diff --git a/src/imap/imap-state.c b/src/imap/imap-state.c index 73332eafa9..b89281de00 100644 --- a/src/imap/imap-state.c +++ b/src/imap/imap-state.c @@ -585,10 +585,12 @@ import_state_mailbox_open(struct client *client, /* verify that this still looks like the same mailbox */ if (mailbox_get_metadata(box, MAILBOX_METADATA_GUID, &metadata) < 0) { *error_r = mailbox_get_last_error(box, NULL); + mailbox_free(&box); return -1; } if (!guid_128_equals(metadata.guid, state->mailbox_guid)) { *error_r = "Mailbox GUID has changed"; + mailbox_free(&box); return -1; } mailbox_get_open_status(box, STATUS_UIDVALIDITY | STATUS_UIDNEXT | @@ -596,14 +598,17 @@ import_state_mailbox_open(struct client *client, STATUS_KEYWORDS, &status); if (status.uidvalidity != state->uidvalidity) { *error_r = "Mailbox UIDVALIDITY has changed"; + mailbox_free(&box); return -1; } if (status.uidnext < state->uidnext) { *error_r = "Mailbox UIDNEXT shrank"; + mailbox_free(&box); return -1; } if (status.highest_modseq < state->highest_modseq) { *error_r = "Mailbox HIGHESTMODSEQ shrank"; + mailbox_free(&box); return -1; }