Skip to content

Commit 5273715

Browse files
committed
Fixed panic error #2211
1 parent e204677 commit 5273715

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

pkg/yqlib/operator_traverse_path.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ func doTraverseMap(newMatches *orderedmap.OrderedMap, node *CandidateNode, wante
264264
// if we don't find a match directly on this node first.
265265

266266
var contents = node.Content
267-
for index := 0; index < len(contents); index = index + 2 {
267+
for index := 0; index+1 < len(contents); index = index + 2 {
268268
key := contents[index]
269269
value := contents[index+1]
270270

pkg/yqlib/operator_traverse_path_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ steps:
3535
`
3636

3737
var traversePathOperatorScenarios = []expressionScenario{
38+
{
39+
skipDoc: true,
40+
description: "strange map with key but no value",
41+
document: "!!null\n-",
42+
expression: ".x",
43+
expected: []string{
44+
"D0, P[x], (!!null)::null\n",
45+
},
46+
},
3847
{
3948
skipDoc: true,
4049
description: "access merge anchors",

0 commit comments

Comments
 (0)