shell32: check result of HeapAlloc()
James Hawkins
truiken at gmail.com
Sun May 13 03:46:03 CDT 2007
On 5/13/07, hto at mail.cnt.ru <hto at mail.cnt.ru> wrote:
> James Hawkins wrote:
> > On 5/12/07, hto at mail.cnt.ru <hto at mail.cnt.ru> wrote:
> >>
> >> --- wine-0.9.37-orig/dlls/shell32/folders.c 2007-05-12
> >> 22:53:06.000000000 +0000
> >> +++ wine-0.9.37/dlls/shell32/folders.c 2007-05-13 00:17:00.000000000
> >> +0000
> >> @@ -81,11 +81,15 @@ IExtractIconW* IExtractIconW_Constructor
> >> TRACE("%p\n", pidl);
> >>
> >> ei = HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIconWImpl));
> >> - ei->ref=1;
> >> - ei->lpVtbl = &eivt;
> >> - ei->lpvtblPersistFile = &pfvt;
> >> - ei->lpvtblExtractIconA = &eiavt;
> >> - ei->pidl=ILClone(pidl);
> >> +
> >> + if (ei)
> >> + {
> >> + ei->ref=1;
> >> + ei->lpVtbl = &eivt;
> >> + ei->lpvtblPersistFile = &pfvt;
> >> + ei->lpvtblExtractIconA = &eiavt;
> >> + ei->pidl=ILClone(pidl);
> >> + }
> >>
> >
> > If a HeapAlloc call fails, you need to return with the appropriate error.
> >
>
> It is already done in ISF_ControlPanel_fnGetUIObjectOf(),
> IShellFolder_fnGetUIObjectOf(), ISF_Desktop_fnGetUIObjectOf(),
> ISF_MyComputer_fnGetUIObjectOf().
>
> ...
> pObj = (LPUNKNOWN) IExtractIconW_Constructor(pidl);
> ...
> if (SUCCEEDED(hr) && !pObj)
> hr = E_OUTOFMEMORY;
> ...
> return hr;
>
Then you need to add an ERR message that the alloc failed, and return
immediately. It'll save an indentation level.
ei = HeapAlloc();
if (!ei)
{
ERR("HeapAlloc failed blah blah\n");
return NULL;
}
--
James Hawkins
More information about the wine-devel
mailing list