Skip to content

Commit 243ffe2

Browse files
author
Claude
committed
fix: nil check before GetToken() dereference in MappingNode traversal
parser.go:469 dereferenced GetToken() without checking for nil, causing a potential panic when traversing MappingNode keys with missing tokens. Other call sites in the same function already guard with nil checks (lines 481, 509); this brings the pattern in line with them.
1 parent 3dd2183 commit 243ffe2

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

parser.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,11 @@ func findKeyPos(node ast.Node, parts []string) (int, int) {
466466
switch n := node.(type) {
467467
case *ast.MappingNode:
468468
for _, mv := range n.Values {
469-
keyVal := mv.Key.GetToken().Value
469+
tok := mv.Key.GetToken()
470+
if tok == nil {
471+
continue
472+
}
473+
keyVal := tok.Value
470474

471475
if keyVal != basePart {
472476
continue

0 commit comments

Comments
 (0)