mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 00:20:42 -05:00
screen-cast/src: Fix unsigned integer overflow
The fields of 'priv->video_format.max_framerate' are all of type uint32_t. Multiplying by G_USEC_PER_SEC can overflow, and equally, dividing a large numerical type by uint32_t can err too. Since the variable holding the result is int64_t, cast all uint32_t fields to int64_t before doing any maths on it. Spotted while trying to investigating an issue with framerates on HDMI screencasts. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2762>
This commit is contained in:
parent
cbf5e6c85d
commit
abfedcb0c3
@ -624,8 +624,8 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src,
|
|||||||
int64_t time_since_last_frame_us;
|
int64_t time_since_last_frame_us;
|
||||||
|
|
||||||
min_interval_us =
|
min_interval_us =
|
||||||
((G_USEC_PER_SEC * priv->video_format.max_framerate.denom) /
|
((G_USEC_PER_SEC * ((int64_t) priv->video_format.max_framerate.denom)) /
|
||||||
priv->video_format.max_framerate.num);
|
((int64_t) priv->video_format.max_framerate.num));
|
||||||
|
|
||||||
time_since_last_frame_us = now_us - priv->last_frame_timestamp_us;
|
time_since_last_frame_us = now_us - priv->last_frame_timestamp_us;
|
||||||
if (time_since_last_frame_us < min_interval_us)
|
if (time_since_last_frame_us < min_interval_us)
|
||||||
|
Loading…
Reference in New Issue
Block a user