Skip to content

Commit 0beeeb2

Browse files
committed
Fix ArraySkip bug in EachKey
1 parent 3f18356 commit 0beeeb2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

parser.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,11 @@ func EachKey(data []byte, cb func(int, []byte, ValueType, error), paths ...[]str
283283
level--
284284
case '[':
285285
// Do not search for keys inside arrays
286-
arraySkip := blockEnd(data[i:], '[', ']')
287-
i += arraySkip - 1
286+
if arraySkip := blockEnd(data[i:], '[', ']'); arraySkip == -1 {
287+
return -1
288+
} else {
289+
i += arraySkip - 1
290+
}
288291
}
289292

290293
i++

0 commit comments

Comments
 (0)