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:
parent
22c2ccfa2a
commit
7f09344989
1 changed files with 3 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue