diff options
| author | Philippe Antoine <contact@catenacyber.fr> | 2022-04-15 11:36:32 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2022-04-16 02:01:19 +0000 |
| commit | 5e4543c29ff930084f79cd982d6eee0f13f52565 (patch) | |
| tree | 60ec38aea4a63aa5734493904c4c62d00628d8ae /src/bytes/bytes.go | |
| parent | e704ef2b8529119a11694b4cb15215d3dd6b0a9f (diff) | |
| download | go-5e4543c29ff930084f79cd982d6eee0f13f52565.tar.xz | |
bytes: explode checks for n too large
As is already done in strings package.
Change-Id: Ia45e6443ddf6beac5e70a1cc493119030e173139
GitHub-Last-Rev: 1174c250350f31eced1513169d62a8a3e679dcf6
GitHub-Pull-Request: golang/go#52348
Reviewed-on: https://go-review.googlesource.com/c/go/+/400239
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Diffstat (limited to 'src/bytes/bytes.go')
| -rw-r--r-- | src/bytes/bytes.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/bytes/bytes.go b/src/bytes/bytes.go index 2a00ce3354..659a82bcc8 100644 --- a/src/bytes/bytes.go +++ b/src/bytes/bytes.go @@ -30,7 +30,7 @@ func Compare(a, b []byte) int { // explode splits s into a slice of UTF-8 sequences, one per Unicode code point (still slices of bytes), // up to a maximum of n byte slices. Invalid UTF-8 sequences are chopped into individual bytes. func explode(s []byte, n int) [][]byte { - if n <= 0 { + if n <= 0 || n > len(s) { n = len(s) } a := make([][]byte, n) |
