handle empty slice case before bounds-check

This commit is contained in:
lukechampine
2020-01-24 12:03:37 -05:00
parent 43ff72405c
commit 07dbf569df
+6
View File
@@ -12,6 +12,9 @@ func Bytes(dst, a, b []byte) int {
if len(dst) < n {
n = len(dst)
}
if n == 0 {
return n
}
_ = dst[n-1]
_ = a[n-1]
_ = b[n-1]
@@ -29,6 +32,9 @@ func Byte(dst, a []byte, b byte) int {
if len(dst) < n {
n = len(dst)
}
if n == 0 {
return n
}
_ = dst[n-1]
_ = a[n-1]
for i := 0; i < n; i++ {