Commit 72a84fbf authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

oleaut32: SafeArrayAllocData should succeed when cbElements is 0.

parent 3e8adc3d
...@@ -228,7 +228,7 @@ static SAFEARRAY* SAFEARRAY_Create(VARTYPE vt, UINT cDims, SAFEARRAYBOUND *rgsab ...@@ -228,7 +228,7 @@ static SAFEARRAY* SAFEARRAY_Create(VARTYPE vt, UINT cDims, SAFEARRAYBOUND *rgsab
if (ulSize) if (ulSize)
psa->cbElements = ulSize; psa->cbElements = ulSize;
if (FAILED(SafeArrayAllocData(psa))) if (!psa->cbElements || FAILED(SafeArrayAllocData(psa)))
{ {
SafeArrayDestroyDescriptor(psa); SafeArrayDestroyDescriptor(psa);
psa = NULL; psa = NULL;
...@@ -533,19 +533,16 @@ HRESULT WINAPI SafeArrayAllocData(SAFEARRAY *psa) ...@@ -533,19 +533,16 @@ HRESULT WINAPI SafeArrayAllocData(SAFEARRAY *psa)
{ {
ULONG ulSize = SAFEARRAY_GetCellCount(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); hRet = S_OK;
TRACE("%u bytes allocated for data at %p (%u objects).\n",
if (psa->pvData) 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; return hRet;
} }
......
...@@ -690,10 +690,7 @@ static void test_SafeArrayAllocDestroyDescriptor(void) ...@@ -690,10 +690,7 @@ static void test_SafeArrayAllocDestroyDescriptor(void)
sa->rgsabound[0].lLbound = 1; sa->rgsabound[0].lLbound = 1;
hres = SafeArrayAllocData(sa); 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) static void test_SafeArrayCreateLockDestroy(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment