mirror of
https://github.com/golang/go
synced 2024-09-15 22:20:06 +00:00
internal: use bytes.Clone
Change-Id: Ia96ddd520a7bd2fd53bff55315c6fac04ae96a2f Reviewed-on: https://go-review.googlesource.com/c/go/+/435282 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
parent
09919ac339
commit
a59e614aa1
|
@ -9,6 +9,7 @@ package encodemeta
|
|||
// instrumentation is turned on.
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
|
@ -82,8 +83,7 @@ func (b *CoverageMetaDataBuilder) AddFunc(f coverage.FuncDesc) uint {
|
|||
lit = 1
|
||||
}
|
||||
b.tmp = uleb128.AppendUleb128(b.tmp, lit)
|
||||
fd.encoded = make([]byte, len(b.tmp))
|
||||
copy(fd.encoded, b.tmp)
|
||||
fd.encoded = bytes.Clone(b.tmp)
|
||||
rv := uint(len(b.funcs))
|
||||
b.funcs = append(b.funcs, fd)
|
||||
return rv
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
package fuzz
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"errors"
|
||||
|
@ -775,8 +776,7 @@ func (c *coordinator) peekInput() (fuzzInput, bool) {
|
|||
warmup: c.warmupRun(),
|
||||
}
|
||||
if c.coverageMask != nil {
|
||||
input.coverageData = make([]byte, len(c.coverageMask))
|
||||
copy(input.coverageData, c.coverageMask)
|
||||
input.coverageData = bytes.Clone(c.coverageMask)
|
||||
}
|
||||
if input.warmup {
|
||||
// No fuzzing will occur, but it should count toward the limit set by
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package fuzz
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os"
|
||||
"unsafe"
|
||||
|
@ -102,9 +103,7 @@ func (m *sharedMem) valueRef() []byte {
|
|||
// valueCopy returns a copy of the value stored in shared memory.
|
||||
func (m *sharedMem) valueCopy() []byte {
|
||||
ref := m.valueRef()
|
||||
b := make([]byte, len(ref))
|
||||
copy(b, ref)
|
||||
return b
|
||||
return bytes.Clone(ref)
|
||||
}
|
||||
|
||||
// setValue copies the data in b into the shared memory buffer and sets
|
||||
|
|
Loading…
Reference in a new issue