diff --git a/vlib/sync/pool.v b/vlib/sync/pool.v index 1998c67415..16c796964f 100644 --- a/vlib/sync/pool.v +++ b/vlib/sync/pool.v @@ -135,6 +135,9 @@ fn process_in_thread(pool mut PoolProcessor, task_id int) { idx = pool.ntask pool.ntask++ pool.ntask_mtx.unlock() + if idx >= ilen { + break + } pool.results[idx] = cb(pool, idx, task_id) } pool.waitgroup.done()