mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-11-08 08:53:43 +08:00
Apply the platform.h memory wrappers across the largest free / realloc hot spots so cleanup paths are uniform and pointers are NULLed on free to prevent accidental use-after-free / double-free. - src/cypher/cypher.c (~85 sites): replace free((void *)x) with safe_str_free(&x) for owned const char * fields; the array-pointer cleanup in parse_in_list error paths uses safe_free(vals) since vals is const char **. - src/store/store.c (~81 sites): same const-string substitution across cbm_search_result_t cleanup, project list, schema info, etc. - src/mcp/mcp.c (~21 sites): same, plus collect_grep_matches growth loop converted to safe_grow(gm, gm_count, gm_cap, PAIR_LEN) — safe here because grep_match_t holds fixed-size char arrays only. - src/pipeline/pass_githistory.c: free_counter callback uses safe_str_free for the hash key. Refactor work cherry-picked from #210; #210 itself bundled .claude/, .github/workflows/, and a stray .claude/worktrees/ submodule that did not belong in the repo, and most of its other changes had landed via #206 / #207 / #208 already. The cypher / store growth-path safe_realloc loops are intentionally NOT converted to safe_grow because their elements own heap pointers — a failed realloc would leak them; the non-destructive realloc + cleanup pattern from #206 is preserved. Co-authored-by: map588 <map588@pitt.edu>