oleaut32: SafeArrayAllocData should succeed when cbElements is 0.

This commit is contained in:
Rob Shearman 2006-12-27 19:14:38 +00:00 committed by Alexandre Julliard
parent 3e8adc3d26
commit 72a84fbf06
2 changed files with 9 additions and 15 deletions
dlls/oleaut32

View File

@ -228,7 +228,7 @@ static SAFEARRAY* SAFEARRAY_Create(VARTYPE vt, UINT cDims, SAFEARRAYBOUND *rgsab
if (ulSize)
psa->cbElements = ulSize;
if (FAILED(SafeArrayAllocData(psa)))
if (!psa->cbElements || FAILED(SafeArrayAllocData(psa)))
{
SafeArrayDestroyDescriptor(psa);
psa = NULL;
@ -533,19 +533,16 @@ HRESULT WINAPI SafeArrayAllocData(SAFEARRAY *psa)
{
ULONG ulSize = SAFEARRAY_GetCellCount(psa);
hRet = E_OUTOFMEMORY;
psa->pvData = SAFEARRAY_Malloc(ulSize * psa->cbElements);
if (psa->cbElements)
if (psa->pvData)
{
psa->pvData = SAFEARRAY_Malloc(ulSize * psa->cbElements);
if (psa->pvData)
{
hRet = S_OK;
TRACE("%u bytes allocated for data at %p (%u objects).\n",
ulSize * psa->cbElements, psa->pvData, ulSize);
}
hRet = S_OK;
TRACE("%u bytes allocated for data at %p (%u objects).\n",
ulSize * psa->cbElements, psa->pvData, ulSize);
}
else
hRet = E_OUTOFMEMORY;
}
return hRet;
}

View File

@ -690,10 +690,7 @@ static void test_SafeArrayAllocDestroyDescriptor(void)
sa->rgsabound[0].lLbound = 1;
hres = SafeArrayAllocData(sa);
todo_wine
{
ok(hres == S_OK, "SafeArrayAllocData gave hres 0x%x\n", hres);
}
ok(hres == S_OK, "SafeArrayAllocData gave hres 0x%x\n", hres);
}
static void test_SafeArrayCreateLockDestroy(void)