From 2aeb1769a26ac727167a3913fa433082388ad55f Mon Sep 17 00:00:00 2001 From: Preetham Narayanareddy Date: Thu, 24 Jun 2021 14:42:26 -0700 Subject: [PATCH] Fix decoding of []byte type --- internal/decoder/bytes.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/decoder/bytes.go b/internal/decoder/bytes.go index e0619be..0c4681a 100644 --- a/internal/decoder/bytes.go +++ b/internal/decoder/bytes.go @@ -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 }