[FFmpeg-devel] [PATCH] lavf/utils: add error check in av_read_frame()

Michael Niedermayer michaelni at gmx.at
Mon Sep 24 19:53:51 CEST 2012


On Mon, Sep 24, 2012 at 07:44:28PM +0200, Stefano Sabatini wrote:
> On date Monday 2012-09-24 17:38:39 +0200, Michael Niedermayer encoded:
> > On Mon, Sep 24, 2012 at 12:43:36AM +0200, Stefano Sabatini wrote:
> > > In particular, fix crash when the input file contains no packets (e.g. an
> > > ffmeta input).
> > > ---
> > >  libavformat/utils.c |   17 ++++++++++++-----
> > >  1 files changed, 12 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/libavformat/utils.c b/libavformat/utils.c
> > > index 6603483..4f3529a 100644
> > > --- a/libavformat/utils.c
> > > +++ b/libavformat/utils.c
> > > @@ -1409,11 +1409,18 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
> > >      AVStream *st;
> > >  
> > >      if (!genpts) {
> > > -        ret = s->packet_buffer ? read_from_packet_buffer(&s->packet_buffer,
> > > -                                                          &s->packet_buffer_end,
> > > -                                                          pkt) :
> > > -                                  read_frame_internal(s, pkt);
> > > -        goto return_packet;
> > > +        while (1) {
> > > +            ret = s->packet_buffer ?
> > > +                read_from_packet_buffer(&s->packet_buffer, &s->packet_buffer_end, pkt) :
> > > +                read_frame_internal(s, pkt);
> > > +            if (ret < 0) {
> > > +                if (ret == AVERROR(EAGAIN))
> > > +                    continue;
> > > +                else
> > > +                    return ret;
> > > +            }
> > > +            goto return_packet;
> > > +        }
> > >      }
> > 
> > this looks very wrong
> > and likely totally breaks non blocking reads as it busy loops
> 
> So please suggest what to do. Indeed I'm not sure about the EAGAIN
> check (would dropping the EAGAIN check be enough?).

id say no loop and ret<0) return ret;

BUT thats what looks correct i dont know if that works ive not tried

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There seems to be only one solution to NIH syndrom, ... a shooting squad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120924/7916fbf7/attachment.asc>


More information about the ffmpeg-devel mailing list