[MPlayer-dev-eng] [PATCH]Fix possible memlead in vo_vdpau

Reimar Döffinger Reimar.Doeffinger at gmx.de
Fri Sep 18 17:46:32 CEST 2009


On Fri, Sep 18, 2009 at 04:42:17PM +0200, Carl Eugen Hoyos wrote:
> Hi!
> 
> I believe attached patch fixes the possible memleak Uoti kindly pointed 
> out.
> 
> Please comment, Carl Eugen

> Index: libvo/vo_vdpau.c
> ===================================================================
> --- libvo/vo_vdpau.c	(revision 29675)
> +++ libvo/vo_vdpau.c	(working copy)
> @@ -479,6 +479,8 @@
>  
>      for (i = 0; i < MAX_VIDEO_SURFACES; i++) {
>          if (surface_render[i].surface != VDP_INVALID_HANDLE) {
> +          av_freep(&surface_render[i].bitstream_buffers);
> +          surface_render[i].bitstream_buffers_allocated = 0;
>            vdp_st = vdp_video_surface_destroy(surface_render[i].surface);
>            CHECK_ST_WARNING("Error when calling vdp_video_surface_destroy")
>          }

This looks wrong to me, bitstream_buffers gets neither overwritten nor
reallocated nor anything here.
I mean it may be correct in principle, but it violates the rule that
things should be closed/freed in the same or a symmetric place to where
they were allocated/opened.
I don't have a suggestion how to fix this right now though (IMO this
should be done on avcodec_close, but this opens up some ugly issues),
but at least I'd suggest to do this in uninit.



More information about the MPlayer-dev-eng mailing list