mirror of https://github.com/goccy/go-json.git
Copy buffer to decode of UnmarshalJSON
This commit is contained in:
parent
305e858ea1
commit
3682ec0cf3
|
@ -57,11 +57,14 @@ func (d *unmarshalJSONDecoder) decode(buf []byte, cursor int64, p unsafe.Pointer
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
src := buf[start:end]
|
src := buf[start:end]
|
||||||
|
dst := make([]byte, len(src))
|
||||||
|
copy(dst, src)
|
||||||
|
|
||||||
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{
|
||||||
typ: d.typ,
|
typ: d.typ,
|
||||||
ptr: p,
|
ptr: p,
|
||||||
}))
|
}))
|
||||||
if err := v.(Unmarshaler).UnmarshalJSON(src); err != nil {
|
if err := v.(Unmarshaler).UnmarshalJSON(dst); err != nil {
|
||||||
d.annotateError(cursor, err)
|
d.annotateError(cursor, err)
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue