[PATCH 2/4] Fix allocation error check for array descriptor
Nikolay Sivov
nsivov at codeweavers.com
Fri Jan 14 14:30:17 CST 2011
---
dlls/oleaut32/safearray.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/dlls/oleaut32/safearray.c b/dlls/oleaut32/safearray.c
index f8f87eb..dd00cfd 100644
--- a/dlls/oleaut32/safearray.c
+++ b/dlls/oleaut32/safearray.c
@@ -172,11 +172,15 @@ static ULONG SAFEARRAY_GetCellCount(const SAFEARRAY *psa)
/* Allocate a descriptor for an array */
static HRESULT SAFEARRAY_AllocDescriptor(ULONG ulSize, SAFEARRAY **ppsaOut)
{
- *ppsaOut = (SAFEARRAY*)((char*)SAFEARRAY_Malloc(ulSize + SAFEARRAY_HIDDEN_SIZE) + SAFEARRAY_HIDDEN_SIZE);
+ char *ptr = SAFEARRAY_Malloc(ulSize + SAFEARRAY_HIDDEN_SIZE);
- if (!*ppsaOut)
- return E_UNEXPECTED;
+ if (!ptr)
+ {
+ *ppsaOut = NULL;
+ return E_UNEXPECTED;
+ }
+ *ppsaOut = (SAFEARRAY*)(ptr + SAFEARRAY_HIDDEN_SIZE);
return S_OK;
}
--
1.5.6.5
--------------070706080703060100000905--
More information about the wine-patches
mailing list