mirror of
https://github.com/golang/go
synced 2024-11-17 05:35:00 -07:00
bytes: explode checks for n too large
As is already done in strings package.
This commit is contained in:
parent
d255203742
commit
1174c25035
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user