mirror of
https://github.com/golang/go
synced 2024-11-20 00:44:45 -07:00
encoding/ascii85: fix panic caused by special case
Special case for encoding 4 zeros as 'z' didn't update source slice, causing 'index out of bounds' panic in destination slice. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5970078
This commit is contained in:
parent
5496e94187
commit
ac51c1384a
@ -57,6 +57,7 @@ func Encode(dst, src []byte) int {
|
||||
if v == 0 && len(src) >= 4 {
|
||||
dst[0] = 'z'
|
||||
dst = dst[1:]
|
||||
src = src[4:]
|
||||
n++
|
||||
continue
|
||||
}
|
||||
|
@ -28,6 +28,11 @@ var pairs = []testpair{
|
||||
"l(DId<j@<?3r@:F%a+D58'ATD4$Bl@l3De:,-DJs`8ARoFb/0JMK@qB4^F!,R<AKZ&-DfTqBG%G\n" +
|
||||
">uD.RTpAKYo'+CT/5+Cei#DII?(E,9)oF*2M7/c\n",
|
||||
},
|
||||
// Special case when shortening !!!!! to z.
|
||||
{
|
||||
"\000\000\000\000",
|
||||
"z",
|
||||
},
|
||||
}
|
||||
|
||||
var bigtest = pairs[len(pairs)-1]
|
||||
|
Loading…
Reference in New Issue
Block a user