mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +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
3 changed files with 6 additions and 7 deletions
|
|
@ -9,6 +9,7 @@ package encodemeta
|
||||||
// instrumentation is turned on.
|
// instrumentation is turned on.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
@ -82,8 +83,7 @@ func (b *CoverageMetaDataBuilder) AddFunc(f coverage.FuncDesc) uint {
|
||||||
lit = 1
|
lit = 1
|
||||||
}
|
}
|
||||||
b.tmp = uleb128.AppendUleb128(b.tmp, lit)
|
b.tmp = uleb128.AppendUleb128(b.tmp, lit)
|
||||||
fd.encoded = make([]byte, len(b.tmp))
|
fd.encoded = bytes.Clone(b.tmp)
|
||||||
copy(fd.encoded, b.tmp)
|
|
||||||
rv := uint(len(b.funcs))
|
rv := uint(len(b.funcs))
|
||||||
b.funcs = append(b.funcs, fd)
|
b.funcs = append(b.funcs, fd)
|
||||||
return rv
|
return rv
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
package fuzz
|
package fuzz
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
@ -775,8 +776,7 @@ func (c *coordinator) peekInput() (fuzzInput, bool) {
|
||||||
warmup: c.warmupRun(),
|
warmup: c.warmupRun(),
|
||||||
}
|
}
|
||||||
if c.coverageMask != nil {
|
if c.coverageMask != nil {
|
||||||
input.coverageData = make([]byte, len(c.coverageMask))
|
input.coverageData = bytes.Clone(c.coverageMask)
|
||||||
copy(input.coverageData, c.coverageMask)
|
|
||||||
}
|
}
|
||||||
if input.warmup {
|
if input.warmup {
|
||||||
// No fuzzing will occur, but it should count toward the limit set by
|
// No fuzzing will occur, but it should count toward the limit set by
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
package fuzz
|
package fuzz
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
@ -102,9 +103,7 @@ func (m *sharedMem) valueRef() []byte {
|
||||||
// valueCopy returns a copy of the value stored in shared memory.
|
// valueCopy returns a copy of the value stored in shared memory.
|
||||||
func (m *sharedMem) valueCopy() []byte {
|
func (m *sharedMem) valueCopy() []byte {
|
||||||
ref := m.valueRef()
|
ref := m.valueRef()
|
||||||
b := make([]byte, len(ref))
|
return bytes.Clone(ref)
|
||||||
copy(b, ref)
|
|
||||||
return b
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// setValue copies the data in b into the shared memory buffer and sets
|
// setValue copies the data in b into the shared memory buffer and sets
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue