From: Timo Sirainen Date: Thu, 25 Mar 2021 13:34:14 +0000 (+0200) Subject: lib-storage: Fix infinite loop in autoexpunging if the mails are already expunged X-Git-Tag: 2.3.16~36 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0e8844adc34c00fc888556fb9b73151b5684951b;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Fix infinite loop in autoexpunging if the mails are already expunged This happens if the mails exist in the index, but mail_get_save_date() fails with MAIL_ERROR_EXPUNGED. --- diff --git a/src/lib-storage/mail-autoexpunge.c b/src/lib-storage/mail-autoexpunge.c index 44ce5dcd21..f00008d895 100644 --- a/src/lib-storage/mail-autoexpunge.c +++ b/src/lib-storage/mail-autoexpunge.c @@ -78,7 +78,6 @@ mailbox_autoexpunge_batch(struct mailbox *box, mail = mail_alloc(t, 0, NULL); hdr = mail_index_get_header(box->view); - done = hdr->messages_count == 0; for (seq = 1; seq <= I_MIN(hdr->messages_count, AUTOEXPUNGE_BATCH_SIZE); seq++) { mail_set_seq(mail, seq); @@ -118,7 +117,7 @@ mailbox_autoexpunge_batch(struct mailbox *box, if (ret < 0) return -1; - return done ? 0 : 1; + return (done || count == 0) ? 0 : 1; } static int