From 862884892441f97c34544557b3804e9b3061c7b1 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Thu, 24 Dec 2020 19:36:49 +0900 Subject: [PATCH] Fix decoding of []byte type --- decode_bytes.go | 5 +++-- decode_test.go | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/decode_bytes.go b/decode_bytes.go index 2b13311..e563c4a 100644 --- a/decode_bytes.go +++ b/decode_bytes.go @@ -65,10 +65,11 @@ func (d *bytesDecoder) decode(buf []byte, cursor int64, p unsafe.Pointer) (int64 cursor = c decodedLen := base64.StdEncoding.DecodedLen(len(bytes)) b := make([]byte, decodedLen) - if _, err := base64.StdEncoding.Decode(b, bytes); err != nil { + n, err := base64.StdEncoding.Decode(b, bytes) + if err != nil { return 0, err } - *(*[]byte)(p) = b + *(*[]byte)(p) = b[:n] return cursor, nil } diff --git a/decode_test.go b/decode_test.go index ff64165..5e401aa 100644 --- a/decode_test.go +++ b/decode_test.go @@ -1864,6 +1864,7 @@ func TestUnmarshalMarshal(t *testing.T) { return } } +*/ var numberTests = []struct { in string @@ -1916,6 +1917,7 @@ func TestLargeByteSlice(t *testing.T) { } } +/* type Xint struct { X int }