oss-fuzz/projects/json-patch/fuzz_decode_apply.go

26 lines
330 B
Go
Raw Normal View History

2021-04-19 12:41:13 +00:00
package jsonpatch
import (
"bytes"
)
func FuzzDecodeApply(data []byte) int {
s := bytes.Split(data, []byte{0})
if len(s) != 2 {
return 0
}
patchJSON := s[0]
original := s[1]
patch, err := DecodePatch(patchJSON)
if err != nil {
return 0
}
_, err = patch.Apply(original)
if err != nil {
return 0
}
return 1
}