diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2022-03-22 21:18:04 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2022-03-22 22:23:56 +0100 |
commit | a2c3ef6d8108355ce5daf6ff72310ac93ae745f0 (patch) | |
tree | a635bd3b161185f2cabe316d29e1cf1d0c538f5b /extensions/source/activex/SOActiveX.cxx | |
parent | a83dc2cebb60ec27a0d2606a9b7c196e581766fd (diff) |
Move BSTR wrapper to systools, and fix some wrong BSTR uses
BSTR is documented [1] to be prefixed by a 32-bit integer specifying
its length *in bytes* (not characters), so passing wchar_t* as BSTR
is wrong, and the length member of rtl_uString can't substitute the
proper BSTR length, since rtl_uString::length specifies length in
characters. Any code taking BSTR and using SysStringLen to get its
length would only get half of the passed OUString data.
In dbaccess/source/ui/dlg/adodatalinks.cxx, the abovementioned
error was implemented. OTOH, OLEVariant::getByteSequence() in
connectivity/source/drivers/ado/Aolevariant.cxx passed BSTR from
tagVARIANT to ctor of OLEString, which resulted in the BSTR being
freed in both dtors of OLEString and OLEVariant (the latter calls
VariantClear, which itself clears string when vtfield is VT_BSTR).
[1] https://docs.microsoft.com/en-us/previous-versions/windows/desktop/automat/bstr
Change-Id: Iedbd62b20133644258af3660616add7b63cac258
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131950
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'extensions/source/activex/SOActiveX.cxx')
-rw-r--r-- | extensions/source/activex/SOActiveX.cxx | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/extensions/source/activex/SOActiveX.cxx b/extensions/source/activex/SOActiveX.cxx index 2d8dc2a73b91..88b3ad7691ca 100644 --- a/extensions/source/activex/SOActiveX.cxx +++ b/extensions/source/activex/SOActiveX.cxx @@ -359,7 +359,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CSOActiveX::Load( LPPROPERTYBAG pPropBag, LPER // all information from the 'object' tag is in strings if (aVal[ind].vt == VT_BSTR && !wcscmp(aPropNames[ind].pstrName, L"src")) { - mCurFileUrl = wcsdup( aVal[ind].bstrVal ); + mCurFileUrl.AssignBSTR(aVal[ind].bstrVal); } else if( aVal[ind].vt == VT_BSTR && !wcscmp(aPropNames[ind].pstrName, L"readonly")) @@ -384,16 +384,10 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CSOActiveX::Load( LPPROPERTYBAG pPropBag, LPER return hr; mbReadyForActivation = FALSE; - if (BSTR bStrUrl = SysAllocString(mCurFileUrl)) - { - hr = CBindStatusCallback<CSOActiveX>::Download( - this, &CSOActiveX::CallbackCreateXInputStream, bStrUrl, m_spClientSite, FALSE); - SysFreeString(bStrUrl); - if (hr == MK_S_ASYNCHRONOUS) - hr = S_OK; - } - else - hr = E_OUTOFMEMORY; + hr = CBindStatusCallback<CSOActiveX>::Download( + this, &CSOActiveX::CallbackCreateXInputStream, mCurFileUrl, m_spClientSite, FALSE); + if (hr == MK_S_ASYNCHRONOUS) + hr = S_OK; if ( !SUCCEEDED( hr ) ) { |