[FFmpeg-devel] [PATCH] alloc_picture needs to free buffer when it's not going to use it

Michael Niedermayer michaelni
Sat Jul 21 16:34:57 CEST 2007


Hi
On Fri, Jul 20, 2007 at 07:18:48PM -0400, Daniel Kristjansson wrote:
> On Fri, 2007-07-20 at 19:55 +0200, Michael Niedermayer wrote:  
> > >          if(r<0 || !pic->age || !pic->type || !pic->data[0]){
> > >              av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %d %p)\n", r, pic->age, pic->type, pic->data[0]);
> > > +            if(r>=0)
> > > +                s->avctx->release_buffer(s->avctx, (AVFrame*)pic);
> > >              return -1;
> > >          }
> > 
> > this is wrong, the general assumtation is that a failing function did the
> > needed cleanup already, we cannot assume that pic is even valid here
> 
> Fair enough.
> 
> > >  
> > >          if(s->linesize && (s->linesize != pic->linesize[0] || s->uvlinesize != pic->linesize[1])){
> > >              av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (stride changed)\n");
> > > +            if(r>=0)
> > > +                s->avctx->release_buffer(s->avctx, (AVFrame*)pic);
> > >              return -1;
> > >          }
> > r cannot by <0 here
> 
> Ok, I've attached a new version removing these two problems and another
> redundant (r>=0) check.

looks ok if regression tests pass

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

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070721/f488deb0/attachment.pgp>



More information about the ffmpeg-devel mailing list