diff options
author | Philippe Antoine <contact@catenacyber.fr> | 2022-03-20 21:34:42 +0000 |
---|---|---|
committer | Tobias Klauser <tobias.klauser@gmail.com> | 2022-03-31 05:24:51 +0000 |
commit | cc46cac3bc59c35e22e17471d70e28fd3705d4da (patch) | |
tree | 5747d4965353da5507413d7ffbf90e6e2ceace5a /src/strings/strings_test.go | |
parent | 90b29e186576d2682c024b0f0b90c6ad98e824d7 (diff) | |
download | go-git-cc46cac3bc59c35e22e17471d70e28fd3705d4da.tar.gz |
strings: limits allocation size for SplitN
So that `strings.SplitN("", "T", int(144115188075855872))` does not panic.
Change-Id: Iea00417e61780bcaf0fee02fa2b18026d89bc545
GitHub-Last-Rev: d1f45b44a8011ddb27c71e1bc9983b62b5d3d771
GitHub-Pull-Request: golang/go#51755
Reviewed-on: https://go-review.googlesource.com/c/go/+/393654
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Diffstat (limited to 'src/strings/strings_test.go')
-rw-r--r-- | src/strings/strings_test.go | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/strings/strings_test.go b/src/strings/strings_test.go index 0f30ca738e..9e7fb85ddf 100644 --- a/src/strings/strings_test.go +++ b/src/strings/strings_test.go @@ -8,6 +8,7 @@ import ( "bytes" "fmt" "io" + "math" "math/rand" "reflect" "strconv" @@ -404,6 +405,7 @@ var splittests = []SplitTest{ {faces, "~", -1, []string{faces}}, {"1 2 3 4", " ", 3, []string{"1", "2", "3 4"}}, {"1 2", " ", 3, []string{"1", "2"}}, + {"", "T", math.MaxInt / 4, []string{""}}, } func TestSplit(t *testing.T) { |