icmstream mem leak fix

James Hawkins truiken at gmail.com
Tue Nov 30 01:55:55 CST 2004


On Tue, 30 Nov 2004 16:32:59 +0900, Mike McCormack <mike at codeweavers.com> wrote:
> 
> 
> James Hawkins wrote:
> 
> > Ignoring the change that I made, what is wrong with the current code?
> > I kindof figured that pstream was tied into ppv, but I wanted to make
> > sure.  If that is the case, then my acmstream patch should be ignored
> > as well.  I thought to call LocalFree on pstream because it was
> > allocated with LocalAlloc.  Can you explain what should be written
> > instead so I don't make the same mistake?
> 
> Actually, the current code will work correctly.  My nitpick is only that
> you should use Release() instead of free() on an interface pointer.
> 
> Mike
> 
> 
> Index: dlls/avifil32/acmstream.c
> ===================================================================
> RCS file: /home/wine/wine/dlls/avifil32/acmstream.c,v
> retrieving revision 1.14
> diff -u -r1.14 acmstream.c
> --- dlls/avifil32/acmstream.c   5 Oct 2004 18:10:21 -0000       1.14
> +++ dlls/avifil32/acmstream.c   30 Nov 2004 08:21:29 -0000
> @@ -118,10 +118,10 @@
>      return AVIERR_MEMORY;
> 
>    pstream->lpVtbl = &iacmst;
> +  pstream->ref = 1;
> 
>    hr = IAVIStream_QueryInterface((IAVIStream*)pstream, riid, ppv);
> -  if (FAILED(hr))
> -    LocalFree((HLOCAL)pstream);
> +  IAVIStream_Release((IAVIStream*)pstream);
> 
>    return hr;
>  }
> 
> 
> 

I just want to make sure I've got this.  Do we want to release even if
the call to QueryInterface suceeds?

-- 
James Hawkins



More information about the wine-devel mailing list