oleaut32: Pass safearray from VARIANT_UserUnmarshal to LPSAFEARRAY_UserUnmarshal so it can be reused.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2016-01-13 09:51:23 +01:00 committed by Alexandre Julliard
parent 3815eca268
commit 37e2acb205
2 changed files with 15 additions and 8 deletions

View File

@ -1370,13 +1370,9 @@ static void test_marshal_VARIANT(void)
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
ok(next == buffer + expected, "got %p expect %p\n", next, buffer + expected);
ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2));
todo_wine ok(lpsa2 == lpsa_copy, "safearray should be reused\n");
ok(lpsa2 == lpsa_copy, "safearray should be reused\n");
todo_wine ok(mem == lpsa2->pvData, "safearray data should be reused\n");
if(lpsa2 != lpsa_copy)
{
lpsa_copy->fFeatures &= ~FADF_STATIC;
SafeArrayDestroy(lpsa_copy);
}
if(mem != lpsa2->pvData) CoTaskMemFree(mem);
ok(SafeArrayGetDim(*V_ARRAYREF(&v)) == SafeArrayGetDim(*V_ARRAYREF(&v2)), "array dims differ\n");
SafeArrayGetLBound(*V_ARRAYREF(&v), 1, &bound);
SafeArrayGetLBound(*V_ARRAYREF(&v2), 1, &bound2);

View File

@ -520,10 +520,16 @@ unsigned char * WINAPI VARIANT_UserUnmarshal(ULONG *pFlags, unsigned char *Buffe
{
VariantClear(pvar);
V_BYREF(pvar) = CoTaskMemAlloc(mem_size);
memset(V_BYREF(pvar), 0, mem_size);
}
else if (!V_BYREF(pvar))
{
V_BYREF(pvar) = CoTaskMemAlloc(mem_size);
memcpy(V_BYREF(pvar), Pos, type_size);
memset(V_BYREF(pvar), 0, mem_size);
}
if(!(header->vt & VT_ARRAY))
memcpy(V_BYREF(pvar), Pos, type_size);
if((header->vt & VT_TYPEMASK) != VT_VARIANT)
Pos += type_size;
else
@ -532,7 +538,9 @@ unsigned char * WINAPI VARIANT_UserUnmarshal(ULONG *pFlags, unsigned char *Buffe
else
{
VariantClear(pvar);
if((header->vt & VT_TYPEMASK) == VT_DECIMAL)
if(header->vt & VT_ARRAY)
V_ARRAY(pvar) = NULL;
else if((header->vt & VT_TYPEMASK) == VT_DECIMAL)
memcpy(pvar, Pos, type_size);
else
memcpy(&pvar->n1.n2.n3, Pos, type_size);
@ -963,6 +971,7 @@ unsigned char * WINAPI LPSAFEARRAY_UserUnmarshal(ULONG *pFlags, unsigned char *B
if (!ptr)
{
SafeArrayDestroy(*ppsa);
*ppsa = NULL;
TRACE("NULL safe array unmarshaled\n");
@ -1001,11 +1010,13 @@ unsigned char * WINAPI LPSAFEARRAY_UserUnmarshal(ULONG *pFlags, unsigned char *B
if(vt)
{
SafeArrayDestroy(*ppsa);
*ppsa = SafeArrayCreateEx(vt, wiresa->cDims, wiresab, NULL);
if (!*ppsa) RpcRaiseException(E_OUTOFMEMORY);
}
else
{
SafeArrayDestroy(*ppsa);
if (FAILED(SafeArrayAllocDescriptor(wiresa->cDims, ppsa)))
RpcRaiseException(E_OUTOFMEMORY);
memcpy((*ppsa)->rgsabound, wiresab, sizeof(SAFEARRAYBOUND) * wiresa->cDims);