From: Timo Sirainen Date: Wed, 1 Dec 2021 10:21:48 +0000 (+0200) Subject: lib-storage: Fix search query that only contains SEARCH_MAILBOX_GUID X-Git-Tag: 2.3.19~107 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7b96f6cbf57b082c0759031f2f7e861664e121f9;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Fix search query that only contains SEARCH_MAILBOX_GUID Fixes assert-crash in virtual mailbox: Panic: file virtual-search.c: line 77 (virtual_search_get_records): assertion failed: (result != 0) --- diff --git a/src/lib-storage/index/index-search-private.h b/src/lib-storage/index/index-search-private.h index a3bf6bdf81..f451b56902 100644 --- a/src/lib-storage/index/index-search-private.h +++ b/src/lib-storage/index/index-search-private.h @@ -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); diff --git a/src/lib-storage/index/index-search.c b/src/lib-storage/index/index-search.c index a094f3c5b3..dec52f3074 100644 --- a/src/lib-storage/index/index-search.c +++ b/src/lib-storage/index/index-search.c @@ -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; }