mirror of
https://github.com/reactos/wine.git
synced 2024-11-29 06:30:37 +00:00
oleaut32: Copying a NULL BSTR should result in an empty BSTR in VariantCopy.
This commit is contained in:
parent
4598c973b2
commit
5e09c29867
@ -528,6 +528,23 @@ static void test_VariantCopy(void)
|
||||
vt | ExtraFlags[i], V_VT(&vDst));
|
||||
}
|
||||
}
|
||||
|
||||
/* Test that copying a NULL BSTR results in an empty BSTR */
|
||||
memset(&vDst, 0, sizeof(vDst));
|
||||
V_VT(&vDst) = VT_EMPTY;
|
||||
memset(&vSrc, 0, sizeof(vSrc));
|
||||
V_VT(&vSrc) = VT_BSTR;
|
||||
hres = VariantCopy(&vDst, &vSrc);
|
||||
ok(hres == S_OK, "Copy(NULL BSTR): Failed to copy a NULL BSTR\n");
|
||||
if (hres == S_OK)
|
||||
{
|
||||
ok((V_VT(&vDst) == VT_BSTR) && V_BSTR(&vDst),
|
||||
"Copy(NULL BSTR): should have non-NULL result\n");
|
||||
if ((V_VT(&vDst) == VT_BSTR) && V_BSTR(&vDst))
|
||||
{
|
||||
ok(*V_BSTR(&vDst) == 0, "Copy(NULL BSTR): result not empty\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Determine if a vt is valid for VariantCopyInd() */
|
||||
|
@ -718,15 +718,12 @@ HRESULT WINAPI VariantCopy(VARIANTARG* pvargDest, VARIANTARG* pvargSrc)
|
||||
}
|
||||
else if (V_VT(pvargSrc) == VT_BSTR)
|
||||
{
|
||||
if (V_BSTR(pvargSrc))
|
||||
{
|
||||
V_BSTR(pvargDest) = SysAllocStringByteLen((char*)V_BSTR(pvargSrc), SysStringByteLen(V_BSTR(pvargSrc)));
|
||||
if (!V_BSTR(pvargDest))
|
||||
{
|
||||
TRACE("!V_BSTR(pvargDest), SysAllocStringByteLen() failed to allocate %d bytes\n", SysStringByteLen(V_BSTR(pvargSrc)));
|
||||
hres = E_OUTOFMEMORY;
|
||||
}
|
||||
}
|
||||
V_BSTR(pvargDest) = SysAllocStringByteLen((char*)V_BSTR(pvargSrc), SysStringByteLen(V_BSTR(pvargSrc)));
|
||||
if (!V_BSTR(pvargDest))
|
||||
{
|
||||
TRACE("!V_BSTR(pvargDest), SysAllocStringByteLen() failed to allocate %d bytes\n", SysStringByteLen(V_BSTR(pvargSrc)));
|
||||
hres = E_OUTOFMEMORY;
|
||||
}
|
||||
}
|
||||
else if (V_VT(pvargSrc) == VT_RECORD)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user