From: Timo Sirainen Date: Thu, 28 Jul 2011 14:46:37 +0000 (+0300) Subject: lib-storage: Fixed crashing on "NOT " search. X-Git-Tag: 2.0.14~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0bcc7b7b453dcf293a7ff863cc395ab06ff01928;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Fixed crashing on "NOT " search. --- diff --git a/src/lib-storage/index/index-search.c b/src/lib-storage/index/index-search.c index 808e9f2529..fbd8a316e5 100644 --- a/src/lib-storage/index/index-search.c +++ b/src/lib-storage/index/index-search.c @@ -745,7 +745,7 @@ static bool search_msgset_fix_limits(unsigned int messages_count, else { /* if all messages are in the range, it can't match */ range = array_get_modifiable(seqset, &count); - return range[0].seq1 != 1 || + return count == 0 || range[0].seq1 != 1 || range[count-1].seq2 != messages_count; } } @@ -768,6 +768,10 @@ static void search_msgset_fix(unsigned int messages_count, if (!not) { min_seq = range[0].seq1; max_seq = range[count-1].seq2; + } else if (count == 0) { + /* matches all messages */ + min_seq = 1; + max_seq = messages_count; } else { min_seq = range[0].seq1 > 1 ? 1 : range[0].seq2 + 1; max_seq = range[count-1].seq2 < messages_count ?