[FFmpeg-devel] [PATCH] mxfdec: fix memleak on read error/EOF.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Fri Apr 20 21:02:36 CEST 2012


On Thu, Apr 19, 2012 at 01:58:57PM +0200, Tomas Härdin wrote:
> On Thu, 2012-04-12 at 20:53 +0200, Reimar Döffinger wrote:
> > This also matches the rest of the demuxer which will return
> > partial packets.
> > 
> > Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
> > ---
> >  libavformat/mxfdec.c |    4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> > index 0782ffe..e5fb7f4 100644
> > --- a/libavformat/mxfdec.c
> > +++ b/libavformat/mxfdec.c
> > @@ -2119,8 +2119,8 @@ static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt)
> >      if ((ret64 = avio_seek(s->pb, pos, SEEK_SET)) < 0)
> >          return ret64;
> >  
> > -        if ((ret = av_get_packet(s->pb, pkt, size)) != size)
> > -            return ret < 0 ? ret : AVERROR_EOF;
> > +        if ((ret = av_get_packet(s->pb, pkt, size)) < 0)
> > +            return ret;
> 
> Looks fine. Maybe a warning of ret < size would be nice?

Pushed with Michael's comments.
I don't think the warning is a good idea, to my knowledge it would
be the only place to raise a warning.
I you think that kind of thing is useful, what I have proposed in other
contexts applies: Add flags (e.g. to AVPacket) that indicate what
kind of issues there are with the packet.
Then the application can decide what to do, e.g. print a warning
message.
And av_get_packet could set that flag to give consistent behaviour
without us bloating the code by adding 100s of checks and warning
message prints.


More information about the ffmpeg-devel mailing list