flvdemux: Avoid integer overflow on invalid CTS

If the CTS is negative an would lead to a negtive PTS, clip
the CTS so the PTS will be 0.

https://bugzilla.gnome.org/show_bug.cgi?id=787795
This commit is contained in:
Nicolas Dufresne 2017-09-23 15:38:07 -04:00
parent 9759283612
commit 18dbd49fb8

View file

@ -1502,6 +1502,12 @@ gst_flv_demux_parse_tag_video (GstFlvDemux * demux, GstBuffer * buffer)
cts = GST_READ_UINT24_BE (data + 9);
cts = (cts + 0xff800000) ^ 0xff800000;
if (cts < 0 && ABS (cts) > dts) {
GST_ERROR_OBJECT (demux, "Detected a negative composition time offset "
"'%d' that would lead to negative PTS, fixing", cts);
cts += ABS (cts) - dts;
}
GST_LOG_OBJECT (demux, "got cts %d", cts);
}