From: Timo Sirainen Date: Mon, 1 Sep 2008 12:30:40 +0000 (+0300) Subject: Thread index bugfix. X-Git-Tag: 1.2.alpha1~14 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9830e764ff6c7ae8686eed461db9e13e2434ba83;p=thirdparty%2Fdovecot%2Fcore.git Thread index bugfix. --HG-- branch : HEAD --- diff --git a/src/lib-storage/index/index-thread.c b/src/lib-storage/index/index-thread.c index ca1368e672..83e51844c8 100644 --- a/src/lib-storage/index/index-thread.c +++ b/src/lib-storage/index/index-thread.c @@ -432,7 +432,15 @@ static void mail_thread_cache_update_adds(struct mail_thread_mailbox *tbox, should already be in msgid_map. */ msgid_map = array_get(tbox->msgid_map, &map_count); uids = array_get(added_uids, &uid_count); - i_assert(uid_count == 0 || msgid_map[j].uid <= uids[0].seq1); + if (uid_count == 0) + return; + + (void)bsearch_insert_pos(&uids[0].seq1, msgid_map, map_count, + sizeof(*msgid_map), msgid_map_cmp, &j); + i_assert(j < map_count); + while (j > 0 && msgid_map[j-1].uid == msgid_map[j].uid) + j--; + for (i = 0; i < uid_count; i++) { for (uid = uids[i].seq1; uid <= uids[i].seq2; uid++) { while (j < map_count && msgid_map[j].uid < uid)