From: Timo Sirainen Date: Tue, 27 Sep 2016 10:28:15 +0000 (+0300) Subject: lib-storage: Update mailbox.recent_flags_count correctly. X-Git-Tag: 2.3.0.rc1~2978 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bf57767df6be53431994f813a8b240b5be180972;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Update mailbox.recent_flags_count correctly. The counter was increased even if the UID was already in recent_flags. This is the only place where I found that recent_flags and recent_flags_count could become desynced (which they definitely were in a core dump), so hopefully this fixes assert-crashes like: Panic: file index-status.c: line 130 (index_storage_get_open_status): assertion failed: (status_r->recent <= status_r->messages) --- diff --git a/src/lib-storage/mailbox-recent-flags.c b/src/lib-storage/mailbox-recent-flags.c index 140fad7798..fe2ecb4246 100644 --- a/src/lib-storage/mailbox-recent-flags.c +++ b/src/lib-storage/mailbox-recent-flags.c @@ -23,8 +23,10 @@ void mailbox_recent_flags_set_uid_forced(struct mailbox *box, uint32_t uid) { box->recent_flags_prev_uid = uid; - seq_range_array_add_with_init(&box->recent_flags, 64, uid); - box->recent_flags_count++; + if (!mailbox_recent_flags_have_uid(box, uid)) { + seq_range_array_add_with_init(&box->recent_flags, 64, uid); + box->recent_flags_count++; + } } void mailbox_recent_flags_set_seqs(struct mailbox *box,