From 344ef36b5a4f84ee536324a5e1db5b2b388de228 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Fri, 3 Jan 2025 11:59:43 +0100 Subject: [PATCH] videorate: Avoid overflow in calculations base_ts and next_end_ts are both guint64. Use explicit check to avoid "negative" timestamps (which would overflow, not be negative). Part-of: --- subprojects/gst-plugins-base/gst/videorate/gstvideorate.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-base/gst/videorate/gstvideorate.c b/subprojects/gst-plugins-base/gst/videorate/gstvideorate.c index 655e299cd1..6a4a591dbb 100644 --- a/subprojects/gst-plugins-base/gst/videorate/gstvideorate.c +++ b/subprojects/gst-plugins-base/gst/videorate/gstvideorate.c @@ -1921,8 +1921,12 @@ gst_video_rate_transform_ip (GstBaseTransform * trans, GstBuffer * buffer) next_ts = videorate->base_ts - ( (videorate->base_ts - next_ts) * videorate->rate); - next_end_ts = videorate->base_ts - (MAX (0, - (videorate->base_ts - next_end_ts)) * videorate->rate); + if (videorate->base_ts > next_end_ts) + next_end_ts = + videorate->base_ts - ((videorate->base_ts - + next_end_ts) * videorate->rate); + else + next_end_ts = videorate->base_ts; diff1 = ABSDIFF (prev_endtime, next_end_ts); diff2 = ABSDIFF (in_endtime, next_end_ts);