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,10 +533,6 @@ HRESULT WINAPI SafeArrayAllocData(SAFEARRAY *psa) ...@@ -533,10 +533,6 @@ HRESULT WINAPI SafeArrayAllocData(SAFEARRAY *psa)
{ {
ULONG ulSize = SAFEARRAY_GetCellCount(psa); ULONG ulSize = SAFEARRAY_GetCellCount(psa);
hRet = E_OUTOFMEMORY;
if (psa->cbElements)
{
psa->pvData = SAFEARRAY_Malloc(ulSize * psa->cbElements); psa->pvData = SAFEARRAY_Malloc(ulSize * psa->cbElements);
if (psa->pvData) if (psa->pvData)
...@@ -545,7 +541,8 @@ HRESULT WINAPI SafeArrayAllocData(SAFEARRAY *psa) ...@@ -545,7 +541,8 @@ HRESULT WINAPI SafeArrayAllocData(SAFEARRAY *psa)
TRACE("%u bytes allocated for data at %p (%u objects).\n", TRACE("%u bytes allocated for data at %p (%u objects).\n",
ulSize * psa->cbElements, psa->pvData, ulSize); 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