Merge pull request #258 from preethamrn/fix-bytes-decodestream

Fix decoding of []byte type
This commit is contained in:
Masaaki Goshima 2021-06-25 12:27:02 +09:00 committed by GitHub
commit 923c0f789e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
}