Skip to content

Commit

Permalink
Fixed panic error #2211
Browse files Browse the repository at this point in the history
  • Loading branch information
mikefarah committed Dec 7, 2024
1 parent e204677 commit 5273715
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/yqlib/operator_traverse_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func doTraverseMap(newMatches *orderedmap.OrderedMap, node *CandidateNode, wante
// if we don't find a match directly on this node first.

var contents = node.Content
for index := 0; index < len(contents); index = index + 2 {
for index := 0; index+1 < len(contents); index = index + 2 {
key := contents[index]
value := contents[index+1]

Expand Down
9 changes: 9 additions & 0 deletions pkg/yqlib/operator_traverse_path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ steps:
`

var traversePathOperatorScenarios = []expressionScenario{
{
skipDoc: true,
description: "strange map with key but no value",
document: "!!null\n-",
expression: ".x",
expected: []string{
"D0, P[x], (!!null)::null\n",
},
},
{
skipDoc: true,
description: "access merge anchors",
Expand Down

0 comments on commit 5273715

Please sign in to comment.