summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMartin Storsjö <[email protected]>2025-09-02 14:10:28 +0300
committerMartin Storsjö <[email protected]>2025-09-02 14:28:56 +0300
commit5a893c180630fe56e027f0f41f2ef04d8309d11f (patch)
tree2d683fd3e1d7417b9045e43d27a9f74fc901f99c /tests
parenta0e00bed88cc06b109e446a8f79833b595dba03a (diff)
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/checkasm/sw_ops.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/checkasm/sw_ops.c b/tests/checkasm/sw_ops.c
index 35ade0c751..57fd501fa1 100644
--- a/tests/checkasm/sw_ops.c
+++ b/tests/checkasm/sw_ops.c
@@ -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)