summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/ado/AViews.cxx
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-03-22 21:18:04 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2022-03-22 22:23:56 +0100
commita2c3ef6d8108355ce5daf6ff72310ac93ae745f0 (patch)
treea635bd3b161185f2cabe316d29e1cf1d0c538f5b /connectivity/source/drivers/ado/AViews.cxx
parenta83dc2cebb60ec27a0d2606a9b7c196e581766fd (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 'connectivity/source/drivers/ado/AViews.cxx')
-rw-r--r--connectivity/source/drivers/ado/AViews.cxx4
1 files changed, 3 insertions, 1 deletions
diff --git a/connectivity/source/drivers/ado/AViews.cxx b/connectivity/source/drivers/ado/AViews.cxx
index 4764833c8829..38f9ae4d7a36 100644
--- a/connectivity/source/drivers/ado/AViews.cxx
+++ b/connectivity/source/drivers/ado/AViews.cxx
@@ -28,6 +28,8 @@
#include <comphelper/types.hxx>
#include <connectivity/dbexception.hxx>
#include <rtl/ref.hxx>
+#include <systools/win32/oleauto.hxx>
+
#include <strings.hrc>
using namespace ::comphelper;
@@ -74,7 +76,7 @@ sdbcx::ObjectType OViews::appendObject( const OUString& _rForName, const Referen
aCommand.put_Name(sName);
aCommand.put_CommandText(getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_COMMAND))));
ADOViews* pViews = m_aCollection;
- if(FAILED(pViews->Append(OLEString(sName).asBSTR(),aCommand)))
+ if (FAILED(pViews->Append(sal::systools::BStr(sName), aCommand)))
ADOS::ThrowException(m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this));
OTables* pTables = static_cast<OTables*>(static_cast<OCatalog&>(m_rParent).getPrivateTables());