Commit ac51c138 authored by Dmitry Chestnykh's avatar Dmitry Chestnykh Committed by Russ Cox

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
parent 5496e941
......@@ -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]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment