From b5b6142df447bafa795931b4e068085a92ca2f89 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 13 Dec 2017 16:31:51 +0100 Subject: 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. --- prog/prio.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'prog/prio.go') 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 } } -- cgit mrf-deployment