frontend/widgets: Fix integer overflow

If the crop values combined are larger than the width or height of the
source, an integer overflow will occur.

This fix converts the width/height values to int, and then clamps
any negative values to 0.
This commit is contained in:
Lain
2025-03-04 16:47:11 -08:00
committed by Ryan Foster
parent 22c2ccfa2a
commit 7f09344989

View File

@@ -414,8 +414,9 @@ static vec2 GetItemSize(obs_sceneitem_t *item)
obs_sceneitem_get_scale(item, &scale);
obs_sceneitem_get_crop(item, &crop);
size.x = float(obs_source_get_width(source) - crop.left - crop.right) * scale.x;
size.y = float(obs_source_get_height(source) - crop.top - crop.bottom) * scale.y;
size.x = fmaxf(float((int)obs_source_get_width(source) - crop.left - crop.right), 0.0f);
size.y = fmaxf(float((int)obs_source_get_height(source) - crop.top - crop.bottom), 0.0f);
vec2_mul(&size, &size, &scale);
}
return size;