[FFmpeg-devel] Fix undefined behavior in ff_configure_buffers_for_index()
Michael Niedermayer
michael at niedermayer.cc
Thu Jan 30 08:23:21 EET 2020
On Wed, Jan 29, 2020 at 03:25:32PM -0800, Dale Curtis wrote:
> On Wed, Jan 29, 2020 at 4:55 AM Michael Niedermayer <michael at niedermayer.cc>
> wrote:
>
> > simpler solution, and also behaves arithmetically more correct when the
> > overflow happens in the othert direction:
> >
> > av_assert0(time_tolerance >= 0);
> >
> > if (e2_pts < e1_pts || e2_pts - (uint64_t)e1_pts < time_tolerance)
> >
>
> Does that work? e1_pts is INT64_MIN in this case. So the (uint64_t)e1_pts >
> e2_pts.
the original code was this:
if (e2_pts - e1_pts < time_tolerance)
time_tolerance is always positive
e2_pts - e1_pts can be either positive or negative
if its negative (e2_pts < e1_pts) then the original would be true and thats
the first term of the new condition
otherwise e2_pts - e1_pts is positive and can be represented as a uint64_t
which is the 2nd term of the new condition
so i think it works but maybe ive missed something, for which values
of e2_pts do you see a problem with e1_pts = INT64_MIN?
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Asymptotically faster algorithms should always be preferred if you have
asymptotical amounts of data
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20200130/ed53036f/attachment.sig>
More information about the ffmpeg-devel
mailing list