Fix decoding of []byte type

This commit is contained in:
Preetham Narayanareddy 2021-06-24 14:42:26 -07:00
parent 397a4e45d3
commit 2aeb1769a2
1 changed files with 3 additions and 2 deletions

View File

@ -49,10 +49,11 @@ func (d *bytesDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) er
}
decodedLen := base64.StdEncoding.DecodedLen(len(bytes))
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
}
*(*[]byte)(p) = buf
*(*[]byte)(p) = buf[:n]
s.reset()
return nil
}