mirror of
https://mirror.skon.top/https://github.com/FFmpeg/FFmpeg
synced 2026-04-20 21:00:41 +08:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user