Fix checkptr validation error on decode

This commit is contained in:
Koichi Shiraishi 2020-11-23 06:47:57 +09:00
parent eee16e83f5
commit e4214835d8
No known key found for this signature in database
GPG Key ID: A71DFD3B4DA7A79B
3 changed files with 6 additions and 6 deletions

View File

@ -32,7 +32,7 @@ func (d *arrayDecoder) decodeStream(s *stream, p unsafe.Pointer) error {
for {
s.cursor++
addr := uintptr(p) + uintptr(idx)*d.size
if err := d.valueDecoder.decodeStream(s, unsafe.Pointer(addr)); err != nil {
if err := d.valueDecoder.decodeStream(s, *(*unsafe.Pointer)(unsafe.Pointer(&addr))); err != nil {
return err
}
s.skipWhiteSpace()
@ -92,7 +92,7 @@ func (d *arrayDecoder) decode(buf []byte, cursor int64, p unsafe.Pointer) (int64
for {
cursor++
addr := uintptr(p) + uintptr(idx)*d.size
c, err := d.valueDecoder.decode(buf, cursor, unsafe.Pointer(addr))
c, err := d.valueDecoder.decode(buf, cursor, *(*unsafe.Pointer)(unsafe.Pointer(&addr)))
if err != nil {
return 0, err
}

View File

@ -91,7 +91,7 @@ func (d *sliceDecoder) decodeStream(s *stream, p unsafe.Pointer) error {
copySlice(d.elemType, dst, src)
}
addr := uintptr(data) + uintptr(idx)*d.size
if err := d.valueDecoder.decodeStream(s, unsafe.Pointer(addr)); err != nil {
if err := d.valueDecoder.decodeStream(s, *(*unsafe.Pointer)(unsafe.Pointer(&addr))); err != nil {
return err
}
s.skipWhiteSpace()
@ -192,7 +192,7 @@ func (d *sliceDecoder) decode(buf []byte, cursor int64, p unsafe.Pointer) (int64
copySlice(d.elemType, dst, src)
}
addr := uintptr(data) + uintptr(idx)*d.size
c, err := d.valueDecoder.decode(buf, cursor, unsafe.Pointer(addr))
c, err := d.valueDecoder.decode(buf, cursor, *(*unsafe.Pointer)(unsafe.Pointer(&addr)))
if err != nil {
return 0, err
}

View File

@ -55,7 +55,7 @@ func (d *structDecoder) decodeStream(s *stream, p unsafe.Pointer) error {
field, exists := d.fieldMap[k]
if exists {
addr := uintptr(p) + field.offset
if err := field.dec.decodeStream(s, unsafe.Pointer(addr)); err != nil {
if err := field.dec.decodeStream(s, *(*unsafe.Pointer)(unsafe.Pointer(&addr))); err != nil {
return err
}
} else if s.disallowUnknownFields {
@ -110,7 +110,7 @@ func (d *structDecoder) decode(buf []byte, cursor int64, p unsafe.Pointer) (int6
field, exists := d.fieldMap[k]
if exists {
addr := uintptr(p) + field.offset
c, err := field.dec.decode(buf, cursor, unsafe.Pointer(addr))
c, err := field.dec.decode(buf, cursor, *(*unsafe.Pointer)(unsafe.Pointer(&addr)))
if err != nil {
return 0, err
}