[FFmpeg-devel] [PATCH] rawdec: add check on sample_rate

Stefano Sabatini stefasab at gmail.com
Fri Oct 28 02:11:56 CEST 2011


On date Thursday 2011-10-27 03:24:09 +0200, Michael Niedermayer encoded:
> On Thu, Oct 27, 2011 at 01:42:30AM +0200, Stefano Sabatini wrote:
> > Prevent error condition in case sample_rate is unset or set to a negative
> > value. In particular, fix divide-by-zero error occurring in ffmpeg due to
> > sample_rate set to 0 in output_packet(), in code:
> > 
> >                 ist->next_pts += ((int64_t)AV_TIME_BASE * ist->st->codec->frame_size) /
> >                     ist->st->codec->sample_rate;
> > 
> > Fix trac ticket #324.
> > ---
> >  libavformat/rawdec.c |   11 ++++++++++-
> >  1 files changed, 10 insertions(+), 1 deletions(-)
> > 
> > diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c
> > index 37e9b0c..f65266b 100644
> > --- a/libavformat/rawdec.c
> > +++ b/libavformat/rawdec.c
> > @@ -46,6 +46,8 @@ int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
> >          st->codec->codec_id = id;
> >  
> >          switch(st->codec->codec_type) {
> > +            int ret = 0;
> > +
> 
> undefined behavior i suspect.

Indeed.

> otherwise LGTM

Applied a simpler variant.
-- 
FFmpeg = Friendly Fancy Mastering Pitiful Ecstatic Gem


More information about the ffmpeg-devel mailing list