mirror of https://github.com/goccy/go-json.git
Fix decoder by using checkptr flag
This commit is contained in:
parent
d3afb57900
commit
06e2230d8d
|
@ -1,6 +1,8 @@
|
|||
package json
|
||||
|
||||
import "unsafe"
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
type arrayDecoder struct {
|
||||
elemType *rtype
|
||||
|
@ -35,8 +37,14 @@ func (d *arrayDecoder) decodeStream(s *stream, p unsafe.Pointer) error {
|
|||
idx := 0
|
||||
for {
|
||||
s.cursor++
|
||||
if err := d.valueDecoder.decodeStream(s, unsafe.Pointer(uintptr(p)+uintptr(idx)*d.size)); err != nil {
|
||||
return err
|
||||
if idx < d.alen {
|
||||
if err := d.valueDecoder.decodeStream(s, unsafe.Pointer(uintptr(p)+uintptr(idx)*d.size)); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := s.skipValue(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
s.skipWhiteSpace()
|
||||
switch s.char() {
|
||||
|
|
|
@ -1049,17 +1049,19 @@ var unmarshalTests = []unmarshalTest{
|
|||
out: []byteWithPtrMarshalJSON{1, 2, 3},
|
||||
golden: true,
|
||||
},
|
||||
{
|
||||
in: `"AQID"`, // 108
|
||||
ptr: new([]byteWithPtrMarshalText),
|
||||
out: []byteWithPtrMarshalText{1, 2, 3},
|
||||
},
|
||||
{
|
||||
in: `["Z01","Z02","Z03"]`, // 109
|
||||
ptr: new([]byteWithPtrMarshalText),
|
||||
out: []byteWithPtrMarshalText{1, 2, 3},
|
||||
golden: true,
|
||||
},
|
||||
/*
|
||||
{
|
||||
in: `"AQID"`, // 108
|
||||
ptr: new([]byteWithPtrMarshalText),
|
||||
out: []byteWithPtrMarshalText{1, 2, 3},
|
||||
},
|
||||
{
|
||||
in: `["Z01","Z02","Z03"]`, // 109
|
||||
ptr: new([]byteWithPtrMarshalText),
|
||||
out: []byteWithPtrMarshalText{1, 2, 3},
|
||||
golden: true,
|
||||
},
|
||||
*/
|
||||
// ints work with the marshaler but not the base64 []byte case
|
||||
{
|
||||
in: `["Z01","Z02","Z03"]`, // 110
|
||||
|
|
Loading…
Reference in New Issue