]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Fix search query that only contains SEARCH_MAILBOX_GUID
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 1 Dec 2021 10:21:48 +0000 (12:21 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 26 Jan 2022 09:15:23 +0000 (09:15 +0000)
Fixes assert-crash in virtual mailbox:

Panic: file virtual-search.c: line 77 (virtual_search_get_records): assertion failed: (result != 0)

src/lib-storage/index/index-search-private.h
src/lib-storage/index/index-search.c

index a3bf6bdf816db91f8a8f9485f3318a1023a48970..f451b5690268fbf8e87487c31b7e185b0aceb482 100644 (file)
@@ -32,6 +32,7 @@ struct index_search_context {
        bool have_seqsets:1;
        bool have_index_args:1;
        bool have_mailbox_args:1;
+       bool have_nonmatch_always:1;
 };
 
 struct mail *index_search_get_mail(struct index_search_context *ctx);
index a094f3c5b33b9f6ad138dc81f1cb014392095f9e..dec52f30742c6c61b9c1d5bbc20ec21ed6e49491 100644 (file)
@@ -122,8 +122,10 @@ static void search_init_arg(struct mail_search_arg *arg,
                               arg->value.str) == 0;
                if (match != arg->match_not)
                        arg->match_always = TRUE;
-               else
+               else {
                        arg->nonmatch_always = TRUE;
+                       ctx->have_nonmatch_always = TRUE;
+               }
                break;
        case SEARCH_MAILBOX:
        case SEARCH_MAILBOX_GLOB:
@@ -132,8 +134,10 @@ static void search_init_arg(struct mail_search_arg *arg,
        case SEARCH_ALL:
                if (!arg->match_not)
                        arg->match_always = TRUE;
-               else
+               else {
                        arg->nonmatch_always = TRUE;
+                       ctx->have_nonmatch_always = TRUE;
+               }
                break;
        default:
                break;
@@ -1874,7 +1878,7 @@ bool index_storage_search_next_update_seq(struct mail_search_context *_ctx)
        }
 
        if (!ctx->have_seqsets && !ctx->have_index_args &&
-           _ctx->update_result == NULL) {
+           !ctx->have_nonmatch_always && _ctx->update_result == NULL) {
                _ctx->progress_cur = _ctx->seq;
                return _ctx->seq <= ctx->seq2;
        }