Skip to content

Commit 63af0e0

Browse files
committed
Fix index out of range panic
Fix a bug shown at https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23083. Credit to OSS-Fuzz.
1 parent 8d8f38b commit 63af0e0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

parser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ func Set(data []byte, setValue []byte, keys ...string) (value []byte, err error)
766766
if endOffset == -1 {
767767
firstToken := nextToken(data)
768768
// We can't set a top-level key if data isn't an object
769-
if len(data) == 0 || data[firstToken] != '{' {
769+
if firstToken < 0 || data[firstToken] != '{' {
770770
return nil, KeyPathNotFoundError
771771
}
772772
// Don't need a comma if the input is an empty object

0 commit comments

Comments
 (0)