From e4a6521ac72c195c3ce0f95fd203ef56839bf7bd Mon Sep 17 00:00:00 2001 From: Robert Rosengren Date: Mon, 11 Apr 2022 13:40:56 +0200 Subject: [PATCH] rtpbin: Fix division by zero when using ts-offset-smoothing-factor avg_ts_offset may cause division by zero when calculating potential overflow protection. This fix will avoid the division. Part-of: --- subprojects/gst-plugins-good/gst/rtpmanager/gstrtpbin.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-good/gst/rtpmanager/gstrtpbin.c b/subprojects/gst-plugins-good/gst/rtpmanager/gstrtpbin.c index d578c03..5181636 100644 --- a/subprojects/gst-plugins-good/gst/rtpmanager/gstrtpbin.c +++ b/subprojects/gst-plugins-good/gst/rtpmanager/gstrtpbin.c @@ -1362,10 +1362,12 @@ stream_set_ts_offset (GstRtpBin * bin, GstRtpBinStream * stream, * ((bin->ts_offset_smoothing_factor - 1) * stream->avg_ts_offset * + ts_offset) / bin->ts_offset_smoothing_factor */ - guint64 max_possible_smoothing_factor = - G_MAXINT64 / ABS (stream->avg_ts_offset); + guint64 max_possible_smoothing_factor = G_MAXUINT64; gint64 cur_avg_product = (bin->ts_offset_smoothing_factor - 1) * stream->avg_ts_offset; + if (stream->avg_ts_offset != 0) + max_possible_smoothing_factor = + G_MAXINT64 / ABS (stream->avg_ts_offset); if ((max_possible_smoothing_factor < bin->ts_offset_smoothing_factor) || (cur_avg_product > 0 && G_MAXINT64 - cur_avg_product < ts_offset) || -- 2.7.4