oleaut32/safearray: Fix allocation error check for array descriptor.

This commit is contained in:
Nikolay Sivov 2011-01-14 23:30:17 +03:00 committed by Alexandre Julliard
parent 30063b5439
commit 90090332a2
1 changed files with 7 additions and 3 deletions

View File

@ -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;
}