]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
don't crash when requesting messages from empty mailbox
authorTimo Sirainen <tss@iki.fi>
Sun, 9 May 2004 23:20:04 +0000 (02:20 +0300)
committerTimo Sirainen <tss@iki.fi>
Sun, 9 May 2004 23:20:04 +0000 (02:20 +0300)
--HG--
branch : HEAD

src/lib-index/mail-index-view.c
src/lib-storage/index/index-search.c

index 6884855db97adf2fda339a452a4f523c86299b13..414239275493dba3dd577716d20d5663f3d95585 100644 (file)
@@ -209,8 +209,7 @@ static uint32_t mail_index_bsearch_uid(struct mail_index_view *view,
 
        rec = view->map->records;
 
-       idx = 0;
-       left_idx = *left_idx_p;
+       idx = left_idx = *left_idx_p;
        right_idx = view->map->records_count;
 
        while (left_idx < right_idx) {
@@ -224,6 +223,11 @@ static uint32_t mail_index_bsearch_uid(struct mail_index_view *view,
                        break;
        }
 
+       if (idx == view->map->records_count) {
+               /* no messages available */
+               return 0;
+       }
+
         *left_idx_p = left_idx;
        if (rec[idx].uid != uid) {
                if (nearest_side > 0) {
index 9c6af48632fe4424421bc0c2603b39c76c1488d0..3535e95d3c2e784c95a0b6a3d90f45cfcadcfe0a 100644 (file)
@@ -691,6 +691,12 @@ static int search_get_seqset(struct index_search_context *ctx,
                return -1;
        }
 
+       if (hdr->messages_count == 0) {
+               ctx->seq1 = 1;
+               ctx->seq2 = 0;
+               return 0;
+       }
+
        if (search_parse_msgset_args(ctx->ibox, hdr, args,
                                     &ctx->seq1, &ctx->seq2) < 0)
                return -1;