shell32: check result of HeapAlloc(), revised
hto at mail.cnt.ru
hto at mail.cnt.ru
Sun May 13 05:57:58 CDT 2007
Add an ERR() messages, save an indentation level.
-------------- next part --------------
--- wine-0.9.37-orig/dlls/shell32/dataobject.c 2007-05-13 10:16:18.000000000 +0000
+++ wine-0.9.37/dlls/shell32/dataobject.c 2007-05-13 10:51:50.000000000 +0000
@@ -169,27 +169,29 @@ static const IEnumFORMATETCVtbl efvt =
LPENUMFORMATETC IEnumFORMATETC_Constructor(UINT cfmt, const FORMATETC afmt[])
{
- IEnumFORMATETCImpl* ef;
- DWORD size=cfmt * sizeof(FORMATETC);
+ IEnumFORMATETCImpl* ef;
+ DWORD size=cfmt * sizeof(FORMATETC);
- ef = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IEnumFORMATETCImpl));
+ ef = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IEnumFORMATETCImpl));
- if(ef)
- {
- ef->ref=1;
- ef->lpVtbl=&efvt;
+ if (!ef)
+ {
+ ERR("HeapAlloc failed\n");
+ return NULL;
+ }
- ef->countFmt = cfmt;
- ef->pFmt = SHAlloc (size);
+ ef->ref=1;
+ ef->lpVtbl=&efvt;
- if (ef->pFmt)
- memcpy(ef->pFmt, afmt, size);
- }
+ ef->countFmt = cfmt;
+ ef->pFmt = SHAlloc (size);
- TRACE("(%p)->(%u,%p)\n",ef, cfmt, afmt);
- return (LPENUMFORMATETC)ef;
-}
+ if (ef->pFmt)
+ memcpy(ef->pFmt, afmt, size);
+ TRACE("(%p)->(%u,%p)\n",ef, cfmt, afmt);
+ return (LPENUMFORMATETC)ef;
+}
/***********************************************************************
* IDataObject implementation
@@ -427,27 +429,30 @@ static const IDataObjectVtbl dtovt =
LPDATAOBJECT IDataObject_Constructor(HWND hwndOwner,
LPCITEMIDLIST pMyPidl, LPCITEMIDLIST * apidl, UINT cidl)
{
- IDataObjectImpl* dto;
+ IDataObjectImpl* dto;
+
+ dto = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDataObjectImpl));
+
+ if (!dto)
+ {
+ ERR("HeapAlloc failed\n");
+ return NULL;
+ }
- dto = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDataObjectImpl));
+ dto->ref = 1;
+ dto->lpVtbl = &dtovt;
+ dto->pidl = ILClone(pMyPidl);
+ dto->apidl = _ILCopyaPidl(apidl, cidl);
+ dto->cidl = cidl;
- if (dto)
- {
- dto->ref = 1;
- dto->lpVtbl = &dtovt;
- dto->pidl = ILClone(pMyPidl);
- dto->apidl = _ILCopyaPidl(apidl, cidl);
- dto->cidl = cidl;
-
- dto->cfShellIDList = RegisterClipboardFormatA(CFSTR_SHELLIDLIST);
- dto->cfFileNameA = RegisterClipboardFormatA(CFSTR_FILENAMEA);
- dto->cfFileNameW = RegisterClipboardFormatA(CFSTR_FILENAMEW);
- InitFormatEtc(dto->pFormatEtc[0], dto->cfShellIDList, TYMED_HGLOBAL);
- InitFormatEtc(dto->pFormatEtc[1], CF_HDROP, TYMED_HGLOBAL);
- InitFormatEtc(dto->pFormatEtc[2], dto->cfFileNameA, TYMED_HGLOBAL);
- InitFormatEtc(dto->pFormatEtc[3], dto->cfFileNameW, TYMED_HGLOBAL);
- }
+ dto->cfShellIDList = RegisterClipboardFormatA(CFSTR_SHELLIDLIST);
+ dto->cfFileNameA = RegisterClipboardFormatA(CFSTR_FILENAMEA);
+ dto->cfFileNameW = RegisterClipboardFormatA(CFSTR_FILENAMEW);
+ InitFormatEtc(dto->pFormatEtc[0], dto->cfShellIDList, TYMED_HGLOBAL);
+ InitFormatEtc(dto->pFormatEtc[1], CF_HDROP, TYMED_HGLOBAL);
+ InitFormatEtc(dto->pFormatEtc[2], dto->cfFileNameA, TYMED_HGLOBAL);
+ InitFormatEtc(dto->pFormatEtc[3], dto->cfFileNameW, TYMED_HGLOBAL);
- TRACE("(%p)->(apidl=%p cidl=%u)\n",dto, apidl, cidl);
- return (LPDATAOBJECT)dto;
+ TRACE("(%p)->(apidl=%p cidl=%u)\n",dto, apidl, cidl);
+ return (LPDATAOBJECT)dto;
}
--- 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 10:51:50.000000000 +0000
@@ -81,6 +81,13 @@ IExtractIconW* IExtractIconW_Constructor
TRACE("%p\n", pidl);
ei = HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIconWImpl));
+
+ if (!ei)
+ {
+ ERR("HeapAlloc failed\n");
+ return NULL;
+ }
+
ei->ref=1;
ei->lpVtbl = &eivt;
ei->lpvtblPersistFile = &pfvt;
--- wine-0.9.37-orig/dlls/shell32/shellole.c 2007-05-13 00:09:56.000000000 +0000
+++ wine-0.9.37/dlls/shell32/shellole.c 2007-05-13 10:51:50.000000000 +0000
@@ -402,6 +402,13 @@ static IClassFactory * IDefClF_fnConstru
IDefClFImpl* lpclf;
lpclf = HeapAlloc(GetProcessHeap(),0,sizeof(IDefClFImpl));
+
+ if (!lpclf)
+ {
+ ERR("HeapAlloc failed\n");
+ return NULL;
+ }
+
lpclf->ref = 1;
lpclf->lpVtbl = &dclfvt;
lpclf->lpfnCI = lpfnCI;
--- wine-0.9.37-orig/dlls/shell32/shlview.c 2007-05-13 00:11:00.000000000 +0000
+++ wine-0.9.37/dlls/shell32/shlview.c 2007-05-13 10:51:50.000000000 +0000
@@ -184,6 +184,11 @@ typedef void (CALLBACK *PFNSHGETSETTINGS
IShellView * IShellView_Constructor( IShellFolder * pFolder)
{ IShellViewImpl * sv;
sv=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IShellViewImpl));
+ if (!sv)
+ {
+ ERR("HeapAlloc failed\n");
+ return NULL;
+ }
sv->ref=1;
sv->lpVtbl=&svvt;
sv->lpvtblOleCommandTarget=&ctvt;
--- wine-0.9.37-orig/dlls/shell32/shv_bg_cmenu.c 2007-05-13 00:10:22.000000000 +0000
+++ wine-0.9.37/dlls/shell32/shv_bg_cmenu.c 2007-05-13 10:51:50.000000000 +0000
@@ -60,6 +60,13 @@ IContextMenu2 *ISvBgCm_Constructor(IShel
BgCmImpl* cm;
cm = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(BgCmImpl));
+
+ if (!cm)
+ {
+ ERR("HeapAlloc failed\n");
+ return NULL;
+ }
+
cm->lpVtbl = &cmvt;
cm->ref = 1;
cm->pSFParent = pSFParent;
--- wine-0.9.37-orig/dlls/shell32/shv_item_cmenu.c 2007-05-13 00:10:26.000000000 +0000
+++ wine-0.9.37/dlls/shell32/shv_item_cmenu.c 2007-05-13 10:51:50.000000000 +0000
@@ -83,6 +83,13 @@ IContextMenu2 *ISvItemCm_Constructor(LPS
UINT u;
cm = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ItemCmImpl));
+
+ if (!cm)
+ {
+ ERR("HeapAlloc failed\n");
+ return NULL;
+ }
+
cm->lpVtbl = &cmvt;
cm->ref = 1;
cm->pidl = ILClone(pidl);
More information about the wine-patches
mailing list