diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-12-13 16:31:51 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-12-17 11:39:14 +0100 |
| commit | b5b6142df447bafa795931b4e068085a92ca2f89 (patch) | |
| tree | 64b9b13b7a51140be2c56c2bc31d0a9b91a856d6 /prog/prio.go | |
| parent | 019cf5f2356fbadb904bb39993ec9e3adb1999c5 (diff) | |
prog: fix off-by-one in ChoiceTable
We need to choose last value inclusice,
otherwise we will never select the last call.
Will be tested by upcoming mutation tests.
Diffstat (limited to 'prog/prio.go')
| -rw-r--r-- | prog/prio.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/prog/prio.go b/prog/prio.go index 110657d8d..c5173fcb3 100644 --- a/prog/prio.go +++ b/prog/prio.go @@ -237,11 +237,10 @@ func (ct *ChoiceTable) Choose(r *rand.Rand, call int) int { return ct.enabledCalls[r.Intn(len(ct.enabledCalls))].ID } for { - x := r.Intn(run[len(run)-1]) + x := r.Intn(run[len(run)-1]) + 1 i := sort.SearchInts(run, x) - if !ct.enabled[ct.target.Syscalls[i]] { - continue + if ct.enabled[ct.target.Syscalls[i]] { + return i } - return i } } |
