From: Timo Sirainen Date: Sun, 9 Jul 2017 08:31:44 +0000 (+0300) Subject: lib-lda: Fix crash if syncing save destination mailbox fails X-Git-Tag: 2.3.0.rc1~1267 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9562831b85e433ae92edd3ea42294578239eff98;p=thirdparty%2Fdovecot%2Fcore.git lib-lda: Fix crash if syncing save destination mailbox fails --- diff --git a/src/lib-lda/mail-deliver.c b/src/lib-lda/mail-deliver.c index 489b54741e..820bd58d0d 100644 --- a/src/lib-lda/mail-deliver.c +++ b/src/lib-lda/mail-deliver.c @@ -410,14 +410,17 @@ int mail_deliver_save(struct mail_deliver_context *ctx, const char *mailbox, if (ctx->save_dest_mail) { /* copying needs the message body. with maildir we also need to get the GUID in case the message gets - expunged */ + expunged. get these early so the copying won't fail + later on. */ i_assert(array_count(&changes.saved_uids) == 1); const struct seq_range *range = array_idx(&changes.saved_uids, 0); i_assert(range->seq1 == range->seq2); ctx->dest_mail = mail_deliver_open_mail(box, range->seq1, MAIL_FETCH_STREAM_BODY | MAIL_FETCH_GUID, &t); - if (mail_get_special(ctx->dest_mail, MAIL_FETCH_GUID, &guid) < 0) { + if (ctx->dest_mail == NULL) { + i_assert(t == NULL); + } else if (mail_get_special(ctx->dest_mail, MAIL_FETCH_GUID, &guid) < 0) { mail_free(&ctx->dest_mail); mailbox_transaction_rollback(&t); }