aboutsummaryrefslogtreecommitdiff
path: root/src/strings/strings.go
diff options
context:
space:
mode:
authorgo101 <tapir.liu@gmail.com>2024-05-03 09:56:47 +0000
committerGopher Robot <gobot@golang.org>2024-05-03 12:58:37 +0000
commit44b54b99c92e6023024e5219be8894a10a8a42fa (patch)
tree9c01532f737d073728eac78c90fa3e6d0ce17866 /src/strings/strings.go
parent2f5b420fb5984842afab37a9c2e66e6599107483 (diff)
downloadgo-44b54b99c92e6023024e5219be8894a10a8a42fa.tar.xz
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: 29dc0cb9c9c63d8a008960b4527d6aa6798c1c17 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>
Diffstat (limited to 'src/strings/strings.go')
-rw-r--r--src/strings/strings.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/strings/strings.go b/src/strings/strings.go
index 11c558c4c3..d8cc09a24e 100644
--- a/src/strings/strings.go
+++ b/src/strings/strings.go
@@ -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