diff --git a/src/encoding/base64/base64.go b/src/encoding/base64/base64.go index 690d3ce0421..0c33f8e5f84 100644 --- a/src/encoding/base64/base64.go +++ b/src/encoding/base64/base64.go @@ -480,15 +480,16 @@ func (enc *Encoding) Decode(dst, src []byte) (n int, err error) { si := 0 for strconv.IntSize >= 64 && len(src)-si >= 8 && len(dst)-n >= 8 { + src2 := src[si : si+8] if dn, ok := assemble64( - enc.decodeMap[src[si+0]], - enc.decodeMap[src[si+1]], - enc.decodeMap[src[si+2]], - enc.decodeMap[src[si+3]], - enc.decodeMap[src[si+4]], - enc.decodeMap[src[si+5]], - enc.decodeMap[src[si+6]], - enc.decodeMap[src[si+7]], + enc.decodeMap[src2[0]], + enc.decodeMap[src2[1]], + enc.decodeMap[src2[2]], + enc.decodeMap[src2[3]], + enc.decodeMap[src2[4]], + enc.decodeMap[src2[5]], + enc.decodeMap[src2[6]], + enc.decodeMap[src2[7]], ); ok { binary.BigEndian.PutUint64(dst[n:], dn) n += 6 @@ -504,11 +505,12 @@ func (enc *Encoding) Decode(dst, src []byte) (n int, err error) { } for len(src)-si >= 4 && len(dst)-n >= 4 { + src2 := src[si : si+4] if dn, ok := assemble32( - enc.decodeMap[src[si+0]], - enc.decodeMap[src[si+1]], - enc.decodeMap[src[si+2]], - enc.decodeMap[src[si+3]], + enc.decodeMap[src2[0]], + enc.decodeMap[src2[1]], + enc.decodeMap[src2[2]], + enc.decodeMap[src2[3]], ); ok { binary.BigEndian.PutUint32(dst[n:], dn) n += 3