From 27c5ea5b5b57887f51d5700398ee283dc191fff9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Wed, 12 Sep 2018 17:23:04 +0200 Subject: [PATCH] random bugs: fix a crash when minOps == maxOps --- misc/random_bugs/create_random_bugs.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/misc/random_bugs/create_random_bugs.go b/misc/random_bugs/create_random_bugs.go index f2d7e7c3..14c2b26f 100644 --- a/misc/random_bugs/create_random_bugs.go +++ b/misc/random_bugs/create_random_bugs.go @@ -72,7 +72,12 @@ func GenerateRandomBugsWithSeed(opts Options, seed int64) []*bug.Bug { panic(err) } - nOps := opts.MinOp + rand.Intn(opts.MaxOp-opts.MinOp) + nOps := opts.MinOp + + if opts.MaxOp > opts.MinOp { + nOps += rand.Intn(opts.MaxOp - opts.MinOp) + } + for j := 0; j < nOps; j++ { index := rand.Intn(len(opsGenerators)) opsGenerators[index](b, randomPerson(opts.PersonNumber))