Skip to content

Commit 6eb8992

Browse files
committed
fix(mcp): share index request cleanup on early exits
Reuse the existing request-string cleanup for cross-repository mode and index-policy load failures. Preserve short-circuit policy loading and the raw string allocator ownership while avoiding duplicate free sites. This addresses the memory-core lint regression in main 92abefa that blocked the test matrix for PR #2005. No lint baseline is relaxed. Signed-off-by: XIYBHK <xiybhk@163.com>
1 parent fcf451c commit 6eb8992

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

‎src/mcp/mcp.c‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11108,21 +11108,17 @@ static char *handle_index_repository(cbm_mcp_server_t *srv, const char *args) {
1110811108
return cbm_mcp_text_result(boundary_err, true);
1110911109
}
1111011110

11111-
if (mode_str && strcmp(mode_str, "cross-repo-intelligence") == 0) {
11112-
free(mode_str);
11113-
char *result = handle_cross_repo_mode(srv, repo_path, name_override, args);
11114-
free(name_override);
11115-
free(repo_path);
11116-
return result;
11117-
}
11118-
11111+
const bool cross_repo_mode = mode_str && strcmp(mode_str, "cross-repo-intelligence") == 0;
1111911112
cbm_index_resource_policy_t resource_policy;
1112011113
char policy_error[CBM_SZ_256] = {0};
11121-
if (!load_index_policy(srv, args, &resource_policy, policy_error, sizeof(policy_error))) {
11114+
if (cross_repo_mode ||
11115+
!load_index_policy(srv, args, &resource_policy, policy_error, sizeof(policy_error))) {
1112211116
free(mode_str);
11117+
char *result = cross_repo_mode ? handle_cross_repo_mode(srv, repo_path, name_override, args)
11118+
: cbm_mcp_text_result(policy_error, true);
1112311119
free(name_override);
1112411120
free(repo_path);
11125-
return cbm_mcp_text_result(policy_error, true);
11121+
return result;
1112611122
}
1112711123

1112811124
/* A daemon session delegates the one physical write to its shared job

0 commit comments

Comments
 (0)