Files
codebase-memory-mcp/tests
Shane McCarronandClaude Sonnet 4.6 822a56f0df fix(mcp): fix use-after-free in handle_manage_adr get path
yyjson_mut_obj_add_str stores the raw pointer without copying. Freeing
buf before yy_doc_to_str serializes the document causes yyjson to read
freed heap memory, producing garbage JSON. cbm_jsonrpc_format_response
then fails to parse the result field (res_doc == NULL), so "result" is
omitted from the JSON-RPC response and the MCP client hangs indefinitely.

Fix: hoist adr_buf to function scope (initialized NULL), remove the
premature free, and free it after yy_doc_to_str has serialized the doc.

Adds regression test tool_manage_adr_get_with_existing_adr that FAILS
before this fix and PASSES after it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-23 08:25:42 -05:00
..