Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

fix(pipeline): preserve allocation policy in resolver cleanup

Martin Vogel4c8c751e1d9f
diff --git a/src/pipeline/pass_parallel.c b/src/pipeline/pass_parallel.c
index 80d7f37b9..96747ef8b 100644
--- a/src/pipeline/pass_parallel.c
+++ b/src/pipeline/pass_parallel.c
@@ -4322,6 +4322,10 @@ int cbm_parallel_resolve(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *files,
return CBM_PIPELINE_ABORT_PRESERVE_DB;
}
+ if (file_count < 0 || (size_t)file_count > SIZE_MAX / sizeof(const char *)) {
+ return CBM_NOT_FOUND;
+ }
+
cbm_log_info("parallel.resolve.start", "files", itoa_log(file_count), "workers",
itoa_log(worker_count));
@@ -4331,7 +4335,8 @@ int cbm_parallel_resolve(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *files,
return CBM_NOT_FOUND;
}
memset(workers, 0, (size_t)worker_count * sizeof(resolve_worker_state_t));
- const char **lsp_failures = calloc((size_t)file_count, sizeof(*lsp_failures));
+ const char **lsp_failures =
+ cbm_calloc(CBM_MEM_CLASS_OTHER, (size_t)file_count * sizeof(*lsp_failures));
if (!lsp_failures) {
cbm_aligned_free(workers);
return CBM_NOT_FOUND;
@@ -4399,7 +4404,7 @@ int cbm_parallel_resolve(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *files,
cbm_pipeline_add_file_error(ctx->pipeline, files[i].rel_path, lsp_failures[i],
"lsp_skipped");
}
- free(lsp_failures);
+ cbm_free(CBM_MEM_CLASS_OTHER, lsp_failures);
/* Workers joined: the shared Rust registry (if built) is no longer read.
* Free its dedicated arena + the lock (registry was self-contained: it strdup'd
* all QNs, so freeing all_defs afterward is safe). */