checkasm: sw_ops: Avoid division by zero

If we're invoked with range == UINT_MAX, we end up doing
"rnd() % (UINT_MAX + 1)", which is equal to "rnd() % 0". On
arm (on all platforms) and on MSVC i386, this ends up crashing
at runtime.

This fixes the crash.
This commit is contained in:
Martin Storsjö
2025-09-02 14:10:28 +03:00
parent a0e00bed88
commit 5a893c1806

View File

@@ -80,7 +80,7 @@ static void fill32f(float *line, int num, unsigned range)
static void fill32(uint32_t *line, int num, unsigned range)
{
for (int i = 0; i < num; i++)
line[i] = range ? rnd() % (range + 1) : rnd();
line[i] = (range && range < UINT_MAX) ? rnd() % (range + 1) : rnd();
}
static void fill16(uint16_t *line, int num, unsigned range)