From 9554bc92ad7fa63b7727bbc4fb040a07002c1ada Mon Sep 17 00:00:00 2001 From: timkoers Date: Mon, 4 Nov 2019 19:36:10 +0100 Subject: [PATCH] Fixed division by zero When the --single flag was used, an division by zero was generated in the munit_rand_state_at_most function. Fixed and tested --- munit.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/munit.c b/munit.c index f6b5194..3ddb508 100644 --- a/munit.c +++ b/munit.c @@ -968,6 +968,11 @@ munit_rand_state_at_most(munit_uint32_t* state, munit_uint32_t salt, munit_uint3 * as (UINT32_MAX + 1 - max) % max = -max % max. We compute -max using not * to avoid compiler warnings. */ + + if(max == 0U){ + return 1; + } + const munit_uint32_t min = (~max + 1U) % max; munit_uint32_t x;