tests/checkasm/sw_ops: fix signed integer related UB when shifting values

Fixes:
src/tests/checkasm/sw_ops.c:441:34: runtime error: shift exponent 32 is too large for 32-bit type 'int'
src/tests/checkasm/sw_ops.c:591:37: runtime error: shift exponent 32 is too large for 32-bit type 'int'

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer 2025-11-20 23:50:44 -03:00
parent 06b3a20761
commit 191f7e4869
1 changed files with 2 additions and 2 deletions

View File

@ -438,7 +438,7 @@ static AVRational rndq(SwsPixelType t)
{
const unsigned num = rnd();
if (ff_sws_pixel_type_is_int(t)) {
const unsigned mask = (1 << (ff_sws_pixel_type_size(t) * 8)) - 1;
const unsigned mask = UINT_MAX >> (32 - ff_sws_pixel_type_size(t) * 8);
return (AVRational) { num & mask, 1 };
} else {
const unsigned den = rnd();
@ -588,7 +588,7 @@ static void check_convert(void)
.convert.to = o,
});
} else if (isize > osize || !ff_sws_pixel_type_is_int(i)) {
uint32_t range = (1 << osize * 8) - 1;
uint32_t range = UINT32_MAX >> (32 - osize * 8);
CHECK_COMMON_RANGE(name, range, i, o, {
.op = SWS_OP_CONVERT,
.type = i,