handle empty slice case before bounds-check
This commit is contained in:
@@ -12,6 +12,9 @@ func Bytes(dst, a, b []byte) int {
|
|||||||
if len(dst) < n {
|
if len(dst) < n {
|
||||||
n = len(dst)
|
n = len(dst)
|
||||||
}
|
}
|
||||||
|
if n == 0 {
|
||||||
|
return n
|
||||||
|
}
|
||||||
_ = dst[n-1]
|
_ = dst[n-1]
|
||||||
_ = a[n-1]
|
_ = a[n-1]
|
||||||
_ = b[n-1]
|
_ = b[n-1]
|
||||||
@@ -29,6 +32,9 @@ func Byte(dst, a []byte, b byte) int {
|
|||||||
if len(dst) < n {
|
if len(dst) < n {
|
||||||
n = len(dst)
|
n = len(dst)
|
||||||
}
|
}
|
||||||
|
if n == 0 {
|
||||||
|
return n
|
||||||
|
}
|
||||||
_ = dst[n-1]
|
_ = dst[n-1]
|
||||||
_ = a[n-1]
|
_ = a[n-1]
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
|
|||||||
Reference in New Issue
Block a user