Skip to content

Commit 25663cd

Browse files
author
HC Hagen
committed
Return error rather than panicking on malformed json where there are more closing brackets than opening brackets
1 parent 6bd1670 commit 25663cd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

parser.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,10 @@ func EachKey(data []byte, cb func(int, []byte, ValueType, error), paths ...[]str
289289
}
290290

291291
if maxPath >= level {
292+
if level < 1 {
293+
cb(-1, []byte{}, Unknown, MalformedJsonError)
294+
return -1
295+
}
292296
pathsBuf[level-1] = bytesToString(&keyUnesc)
293297

294298
for pi, p := range paths {

0 commit comments

Comments
 (0)