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 /avmedia/source | |
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 'avmedia/source')
-rw-r--r-- | avmedia/source/win/framegrabber.cxx | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/avmedia/source/win/framegrabber.cxx b/avmedia/source/win/framegrabber.cxx index a2adc90b7072..547b3ffa6a59 100644 --- a/avmedia/source/win/framegrabber.cxx +++ b/avmedia/source/win/framegrabber.cxx @@ -38,6 +38,7 @@ #include <vcl/graph.hxx> #include <vcl/dibtools.hxx> #include <o3tl/char16_t2wchar_t.hxx> +#include <systools/win32/oleauto.hxx> constexpr OUStringLiteral AVMEDIA_WIN_FRAMEGRABBER_IMPLEMENTATIONNAME = u"com.sun.star.comp.avmedia.FrameGrabber_DirectX"; constexpr OUStringLiteral AVMEDIA_WIN_FRAMEGRABBER_SERVICENAME = u"com.sun.star.media.FrameGrabber_DirectX"; @@ -69,15 +70,8 @@ sal::systools::COMReference<IMediaDet> implCreateMediaDet( const OUString& rURL if( osl::FileBase::getSystemPathFromFileURL( rURL, aLocalStr ) == osl::FileBase::E_None ) { - BSTR bstrFilename = SysAllocString(o3tl::toW(aLocalStr.getStr())); - if( !SUCCEEDED( pDet->put_Filename( bstrFilename ) ) ) - { - // Shouldn't we free this string unconditionally, not only in case of failure? - // I cannot find information why do we pass a newly allocated BSTR to the put_Filename - // and if it frees the string internally - SysFreeString(bstrFilename); + if( !SUCCEEDED( pDet->put_Filename(sal::systools::BStr(aLocalStr)) ) ) pDet.clear(); - } } } |