]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
virtual: virtual_search_next_update_seq() - Do not crash if next_update_seq is no...
authorMarco Bettini <marco.bettini@open-xchange.com>
Thu, 5 Mar 2026 11:28:34 +0000 (11:28 +0000)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 11 Mar 2026 12:36:15 +0000 (12:36 +0000)
src/plugins/virtual/virtual-search.c

index 6393f6a2a715ee54686a040c7871eb9c1e39a065..7d12f15df6466bd1df1d26c47a2d1b74b494c137 100644 (file)
@@ -186,13 +186,14 @@ bool virtual_search_next_update_seq(struct mail_search_context *ctx)
        unsigned int count;
 
        recs = array_get(&vctx->records, &count);
-       if (vctx->next_record_idx < count) {
+       while (vctx->next_record_idx < count) {
                /* go through potential results first */
                ctx->seq = recs[vctx->next_record_idx++].virtual_seq - 1;
-               if (!index_storage_search_next_update_seq(ctx))
-                       i_unreached();
-               ctx->progress_cur = vctx->next_record_idx;
-               return TRUE;
+               if (index_storage_search_next_update_seq(ctx)) {
+                       ctx->progress_cur = vctx->next_record_idx;
+                       return TRUE;
+               }
+               /* the message was lost or otherwise not found, try next one */
        }
 
        if (ctx->sort_program != NULL &&