aboutsummaryrefslogtreecommitdiff
path: root/src/internal
diff options
context:
space:
mode:
authorRoland Shoemaker <roland@golang.org>2021-11-18 13:30:55 -0800
committerRoland Shoemaker <roland@golang.org>2021-11-19 17:42:26 +0000
commita94409660dbf05c1cdc2013aa2c7aa2489fe5c1c (patch)
tree14f9ea0e37f6b1b023655740318797ce7d346ad6 /src/internal
parente8cda0a6c925668972ada40602ada08468fa90dc (diff)
downloadgo-a94409660dbf05c1cdc2013aa2c7aa2489fe5c1c.tar.gz
go-a94409660dbf05c1cdc2013aa2c7aa2489fe5c1c.zip
internal/fuzz: compute correct number of mutations
When reconstructing inputs, we miscalculated the number of mutations that needed to be applied. If the count%chainedMutation == 0 we would apply 0 mutations, when we should actually be applying chainedMutation mutations, due to how count is incremented. Fixes #49047 Change-Id: I76773bff0afd6dfd40deafc317be095da995ecc5 Reviewed-on: https://go-review.googlesource.com/c/go/+/365294 Trust: Roland Shoemaker <roland@golang.org> Trust: Katie Hockman <katie@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Katie Hockman <katie@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/fuzz/worker.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/internal/fuzz/worker.go b/src/internal/fuzz/worker.go
index e7d824bea1..5be49d28f9 100644
--- a/src/internal/fuzz/worker.go
+++ b/src/internal/fuzz/worker.go
@@ -1111,7 +1111,8 @@ func (wc *workerClient) fuzz(ctx context.Context, entryIn CorpusEntry, args fuzz
wc.m.r.restore(mem.header().randState, mem.header().randInc)
if !args.Warmup {
// Only mutate the valuesOut if fuzzing actually occurred.
- for i := int64(0); i < resp.Count%chainedMutations; i++ {
+ numMutations := ((resp.Count - 1) % chainedMutations) + 1
+ for i := int64(0); i < numMutations; i++ {
wc.m.mutate(valuesOut, cap(mem.valueRef()))
}
}