]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Fixed crashing on "NOT <nonexistent sequence>" search.
authorTimo Sirainen <tss@iki.fi>
Thu, 28 Jul 2011 14:46:37 +0000 (17:46 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 28 Jul 2011 14:46:37 +0000 (17:46 +0300)
src/lib-storage/index/index-search.c

index 808e9f2529823c6349bc7b3d65dc2f706918c6be..fbd8a316e516f25f30797cac65416ec98a95687b 100644 (file)
@@ -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 ?