Commit 37e2acb2 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

oleaut32: Pass safearray from VARIANT_UserUnmarshal to LPSAFEARRAY_UserUnmarshal…

oleaut32: Pass safearray from VARIANT_UserUnmarshal to LPSAFEARRAY_UserUnmarshal so it can be reused. Signed-off-by: 's avatarPiotr Caban <piotr@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 3815eca2
...@@ -1370,13 +1370,9 @@ static void test_marshal_VARIANT(void) ...@@ -1370,13 +1370,9 @@ static void test_marshal_VARIANT(void)
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2); next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
ok(next == buffer + expected, "got %p expect %p\n", next, buffer + expected); 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)); 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"); todo_wine ok(mem == lpsa2->pvData, "safearray data should be reused\n");
if(lpsa2 != lpsa_copy) if(mem != lpsa2->pvData) CoTaskMemFree(mem);
{
lpsa_copy->fFeatures &= ~FADF_STATIC;
SafeArrayDestroy(lpsa_copy);
}
ok(SafeArrayGetDim(*V_ARRAYREF(&v)) == SafeArrayGetDim(*V_ARRAYREF(&v2)), "array dims differ\n"); ok(SafeArrayGetDim(*V_ARRAYREF(&v)) == SafeArrayGetDim(*V_ARRAYREF(&v2)), "array dims differ\n");
SafeArrayGetLBound(*V_ARRAYREF(&v), 1, &bound); SafeArrayGetLBound(*V_ARRAYREF(&v), 1, &bound);
SafeArrayGetLBound(*V_ARRAYREF(&v2), 1, &bound2); SafeArrayGetLBound(*V_ARRAYREF(&v2), 1, &bound2);
......
...@@ -520,10 +520,16 @@ unsigned char * WINAPI VARIANT_UserUnmarshal(ULONG *pFlags, unsigned char *Buffe ...@@ -520,10 +520,16 @@ unsigned char * WINAPI VARIANT_UserUnmarshal(ULONG *pFlags, unsigned char *Buffe
{ {
VariantClear(pvar); VariantClear(pvar);
V_BYREF(pvar) = CoTaskMemAlloc(mem_size); V_BYREF(pvar) = CoTaskMemAlloc(mem_size);
memset(V_BYREF(pvar), 0, mem_size);
} }
else if (!V_BYREF(pvar)) else if (!V_BYREF(pvar))
{
V_BYREF(pvar) = CoTaskMemAlloc(mem_size); 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) if((header->vt & VT_TYPEMASK) != VT_VARIANT)
Pos += type_size; Pos += type_size;
else else
...@@ -532,7 +538,9 @@ unsigned char * WINAPI VARIANT_UserUnmarshal(ULONG *pFlags, unsigned char *Buffe ...@@ -532,7 +538,9 @@ unsigned char * WINAPI VARIANT_UserUnmarshal(ULONG *pFlags, unsigned char *Buffe
else else
{ {
VariantClear(pvar); 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); memcpy(pvar, Pos, type_size);
else else
memcpy(&pvar->n1.n2.n3, Pos, type_size); memcpy(&pvar->n1.n2.n3, Pos, type_size);
...@@ -963,6 +971,7 @@ unsigned char * WINAPI LPSAFEARRAY_UserUnmarshal(ULONG *pFlags, unsigned char *B ...@@ -963,6 +971,7 @@ unsigned char * WINAPI LPSAFEARRAY_UserUnmarshal(ULONG *pFlags, unsigned char *B
if (!ptr) if (!ptr)
{ {
SafeArrayDestroy(*ppsa);
*ppsa = NULL; *ppsa = NULL;
TRACE("NULL safe array unmarshaled\n"); TRACE("NULL safe array unmarshaled\n");
...@@ -1001,11 +1010,13 @@ unsigned char * WINAPI LPSAFEARRAY_UserUnmarshal(ULONG *pFlags, unsigned char *B ...@@ -1001,11 +1010,13 @@ unsigned char * WINAPI LPSAFEARRAY_UserUnmarshal(ULONG *pFlags, unsigned char *B
if(vt) if(vt)
{ {
SafeArrayDestroy(*ppsa);
*ppsa = SafeArrayCreateEx(vt, wiresa->cDims, wiresab, NULL); *ppsa = SafeArrayCreateEx(vt, wiresa->cDims, wiresab, NULL);
if (!*ppsa) RpcRaiseException(E_OUTOFMEMORY); if (!*ppsa) RpcRaiseException(E_OUTOFMEMORY);
} }
else else
{ {
SafeArrayDestroy(*ppsa);
if (FAILED(SafeArrayAllocDescriptor(wiresa->cDims, ppsa))) if (FAILED(SafeArrayAllocDescriptor(wiresa->cDims, ppsa)))
RpcRaiseException(E_OUTOFMEMORY); RpcRaiseException(E_OUTOFMEMORY);
memcpy((*ppsa)->rgsabound, wiresab, sizeof(SAFEARRAYBOUND) * wiresa->cDims); memcpy((*ppsa)->rgsabound, wiresab, sizeof(SAFEARRAYBOUND) * wiresa->cDims);
......
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