mlang: fix memory leaks in error path (found by Smatch).
Dmitry Timoshkov
dmitry at codeweavers.com
Mon Sep 24 07:54:11 CDT 2007
"Tijl Coosemans" <tijl at ulyssis.org> wrote:
> > hr = ConvertINetMultiByteToUnicode(pdwMode, dwSrcEncoding, pSrcStr, pcSrcSize, pDstStrW, &cDstSizeW);
> > if (hr != S_OK)
> > - return hr;
> > + goto cleanup;
> >
> > hr = ConvertINetUnicodeToMultiByte(pdwMode, dwDstEncoding, pDstStrW, &cDstSizeW, pDstStr, pcDstSize);
> > +cleanup:
> > HeapFree(GetProcessHeap(), 0, pDstStrW);
> > return hr;
> > }
>
> This is a bikeshed issue really, but I wonder what Wine's policy on
> gotos like this is. Imo, it's better to add the HeapFree call to the if
> block and let the compiler work it out.
In this particular case goto should be avoided IMO by rewriting code
snippet like below:
if (hr == S_OK)
hr = ConvertINetUnicodeToMultiByte(...);
--
Dmitry.
More information about the wine-devel
mailing list