[FFmpeg-devel] [PATCH 01/12] Make av_d2q() manage the case where d is infinite.
Stefano Sabatini
stefano.sabatini-lala
Fri Oct 1 20:55:08 CEST 2010
On date Friday 2010-10-01 20:36:10 +0200, Michael Niedermayer encoded:
> On Fri, Oct 01, 2010 at 06:08:49PM +0200, Stefano Sabatini wrote:
> > ---
> > libavutil/rational.c | 2 ++
> > libavutil/rational.h | 2 ++
> > 2 files changed, 4 insertions(+), 0 deletions(-)
> >
> > diff --git a/libavutil/rational.c b/libavutil/rational.c
> > index 0e0571e..b5af28e 100644
> > --- a/libavutil/rational.c
> > +++ b/libavutil/rational.c
> > @@ -98,6 +98,8 @@ AVRational av_d2q(double d, int max){
> > #define LOG2 0.69314718055994530941723212145817656807550013436025
> > int exponent= FFMAX( (int)(log(fabs(d) + 1e-20)/LOG2), 0);
> > int64_t den= 1LL << (61 - exponent);
> > + if (isinf(d))
> > + return (AVRational){1,0};
>
> if iam not mistaken then the int cast above has undefined behavior in this case
Why?
Note that one line below there is:
if (isnan(d))
return (AVRational){0,0};
Regards.
--
FFmpeg = Foolish Foolish Monstrous Ponderous Empowered Gargoyle
More information about the ffmpeg-devel
mailing list