-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Milestone
Description
- What version of Go are you using (
go version
)?
go version go1.6.2 linux/amd64 - What operating system and processor architecture are you using (
go env
)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/pat/go"
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1" - What did you do?
https://play.golang.org/p/o-5UiG_cKc - What did you expect to see?
A panic because the program tries to allocate too much memory. - What did you see instead?
Both bytes.Repeat and strings.Repeat appear to succeed, but the result is shorter than the input string.
Looking at https://golang.org/src/bytes/bytes.go?s=9819:9858#L381, the cause seems to be that len(b)*count overflows, and happens to produce a result that is a small positive integer. Perhaps the routine should check for overflow and panic if one occurs.