oleaut32: Fix size of memory allocated for byrefs in VARIANT_UserMarshal.

This commit is contained in:
Rob Shearman 2009-11-25 09:54:27 +00:00 committed by Alexandre Julliard
parent 6ed98b16a1
commit 489b73dd9e
1 changed files with 17 additions and 2 deletions

View File

@ -552,14 +552,29 @@ unsigned char * WINAPI VARIANT_UserUnmarshal(ULONG *pFlags, unsigned char *Buffe
if(header->vt & VT_BYREF)
{
ULONG mem_size;
Pos += 4;
switch (header->vt & ~VT_BYREF)
{
/* these types have a different memory size compared to wire size */
case VT_UNKNOWN:
case VT_DISPATCH:
case VT_BSTR:
mem_size = sizeof(void *);
break;
default:
mem_size = type_size;
break;
}
if (V_VT(pvar) != header->vt)
{
VariantClear(pvar);
V_BYREF(pvar) = CoTaskMemAlloc(type_size);
V_BYREF(pvar) = CoTaskMemAlloc(mem_size);
}
else if (!V_BYREF(pvar))
V_BYREF(pvar) = CoTaskMemAlloc(type_size);
V_BYREF(pvar) = CoTaskMemAlloc(mem_size);
memcpy(V_BYREF(pvar), Pos, type_size);
if((header->vt & VT_TYPEMASK) != VT_VARIANT)
Pos += type_size;