mirror of https://github.com/goccy/go-json.git
Merge pull request #258 from preethamrn/fix-bytes-decodestream
Fix decoding of []byte type
This commit is contained in:
commit
923c0f789e
|
@ -49,10 +49,11 @@ func (d *bytesDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) er
|
||||||
}
|
}
|
||||||
decodedLen := base64.StdEncoding.DecodedLen(len(bytes))
|
decodedLen := base64.StdEncoding.DecodedLen(len(bytes))
|
||||||
buf := make([]byte, decodedLen)
|
buf := make([]byte, decodedLen)
|
||||||
if _, err := base64.StdEncoding.Decode(buf, bytes); err != nil {
|
n, err := base64.StdEncoding.Decode(buf, bytes)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
*(*[]byte)(p) = buf
|
*(*[]byte)(p) = buf[:n]
|
||||||
s.reset()
|
s.reset()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue