]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: Free box on error
authorAki Tuomi <aki.tuomi@dovecot.fi>
Tue, 8 Nov 2016 18:41:15 +0000 (20:41 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 9 Nov 2016 12:53:05 +0000 (14:53 +0200)
Otherwise the box wil leak as it is not assigned
anywhere and can cause crash on imap exit due
to stats plugin timeout leak.

src/imap/imap-state.c

index 73332eafa90c296a29e010749d75d9aaba39c086..b89281de0084c5af0893a6c620c3b037eece8c21 100644 (file)
@@ -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;
        }