Skip to content

Commit db8d547

Browse files
committed
fix(extract): keep both Go method QN sides flat when the type QN is NULL
cbm_fqn_compute_source_lang returns NULL only when the module QN cannot be built (arena exhaustion). The receiver-qualified branches then passed that NULL to "%s". Both sides now fall back to the flat QN together, so the def and its calls still agree. Allocation-failure path only; no change on any normal run. (Raised in our security review of the updated head.) Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 87cafb9 commit db8d547

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎internal/cbm/extract_defs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6700,7 +6700,7 @@ static void extract_func_def(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec
67006700
* branch too, but its call-scope QN (compute_func_qn) stays flat,
67016701
* and a def QN the calls do not share would orphan every call
67026702
* inside a templ method. */
6703-
if (ctx->language == CBM_LANG_GO) {
6703+
if (ctx->language == CBM_LANG_GO && def.parent_class) {
67046704
def.qualified_name = cbm_arena_sprintf(a, "%s.%s", def.parent_class, name);
67056705
}
67066706
}

‎internal/cbm/extract_unified.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,11 @@ static const char *compute_func_qn(CBMExtractCtx *ctx, TSNode node, const CBMLan
11091109
if (recv_type && recv_type[0]) {
11101110
const char *type_qn = cbm_fqn_compute_source_lang(
11111111
ctx->arena, ctx->project, ctx->rel_path, recv_type, ctx->language);
1112-
return cbm_arena_sprintf(ctx->arena, "%s.%s", type_qn, name);
1112+
/* NULL only on allocation failure: fall through to the flat
1113+
* QN, as the def side does (extract_defs.c). */
1114+
if (type_qn) {
1115+
return cbm_arena_sprintf(ctx->arena, "%s.%s", type_qn, name);
1116+
}
11131117
}
11141118
}
11151119
}

0 commit comments

Comments
 (0)