oleaut32: Copying a NULL BSTR should result in an empty BSTR
in VariantCopy
Robert Shearman
rob at codeweavers.com
Fri Jul 7 11:49:26 CDT 2006
qingdoa daoo wrote:
>Hi,
>
>This patch should fix Bug 4141
>
>Changelog:
> Copying a NULL BSTR should result in an empty BSTR in VariantCopy
>
>------------------------------------------------------------------------
>
>--- dlls/oleaut32/variant.c.cvs 2006-07-05 17:23:04.000000000 +0800
>+++ dlls/oleaut32/variant.c 2006-07-05 17:31:53.000000000 +0800
>@@ -719,13 +719,16 @@ HRESULT WINAPI VariantCopy(VARIANTARG* p
> 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;
>- }
>+ else
>+ {
>+ OLECHAR c = 0;
>+ V_BSTR(pvargDest) = SysAllocString(&c);
>+ }
>+ if (!V_BSTR(pvargDest))
>+ {
>+ TRACE("Allocation failed for destination BSTR\n");
>+ hres = E_OUTOFMEMORY;
> }
> }
> else if (V_VT(pvargSrc) == VT_RECORD)
>
>
I think you could get the same result by just removing the "if
(V_BSTR(pvargSrc)" check. This should result in simpler code.
--
Rob Shearman
More information about the wine-devel
mailing list