mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
strings,bytes: improve Repeat panic messages
The Repeat("-", maxInt) call should produce
panic: runtime error: makeslice: len out of range
instead of
panic: strings: Repeat output length overflow
This PR is only for theory perfection.
Change-Id: If67d87b147d666fbbb7238656f2a0cb6cf1dbb5b
GitHub-Last-Rev: 29dc0cb9c9
GitHub-Pull-Request: golang/go#67068
Reviewed-on: https://go-review.googlesource.com/c/go/+/581936
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
This commit is contained in:
parent
2f5b420fb5
commit
44b54b99c9
4 changed files with 64 additions and 34 deletions
|
|
@ -570,7 +570,7 @@ func Repeat(s string, count int) string {
|
|||
if count < 0 {
|
||||
panic("strings: negative Repeat count")
|
||||
}
|
||||
if len(s) >= maxInt/count {
|
||||
if len(s) > maxInt/count {
|
||||
panic("strings: Repeat output length overflow")
|
||||
}
|
||||
n := len(s) * count
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue