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

Daniel Kristjansson danielk
Sat Jul 21 01:18:48 CEST 2007


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.

-- Daniel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: alloc_picture_leak_with_allocz-v2.patch
Type: text/x-patch
Size: 1363 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070720/78e18a02/attachment.bin>



More information about the ffmpeg-devel mailing list