[FFmpeg-devel] [PATCH] make av_set_pts_info more robust

Reimar Döffinger Reimar.Doeffinger
Wed Jul 1 22:52:22 CEST 2009


On Wed, Jul 01, 2009 at 10:23:24PM +0200, Michael Niedermayer wrote:
> On Wed, Jul 01, 2009 at 08:39:50PM +0200, Reimar D?ffinger wrote:
> > Hello,
> > I don't have a sample file for the issue, but the AVI demuxer and probably
> > more pass on user data unchecked to av_set_pts_info.
> > So I propose to change it in a way that will avoid a division by 0.
> > Not sure if that's the best idea, but it seemed like a good idea (I
> > originally thought this was the cause of a crash I am investigating).
> > Index: libavformat/utils.c
> > ===================================================================
> > --- libavformat/utils.c	(revision 19317)
> > +++ libavformat/utils.c	(working copy)
> > @@ -3308,8 +3308,10 @@
> >  {
> >      unsigned int gcd= av_gcd(pts_num, pts_den);
> >      s->pts_wrap_bits = pts_wrap_bits;
> > +    if (pts_num > 0 && pts_den > 0) {
> >      s->time_base.num = pts_num/gcd;
> >      s->time_base.den = pts_den/gcd;
> > +    }
> 
> rejected, this is definitly not reasonable

Agreed, I did not read the code right, and AVI at least does check the values
(no idea how I missed that).
There are demuxers like xa that don't do sufficient checking but it is probably
better to fix in the demuxers (I fear we have no volunteers?).



More information about the ffmpeg-devel mailing list