From 1c763a6b88c2efd425e764778fc8c709387cf2ff Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sat, 25 Jan 2025 18:50:42 +0500 Subject: [PATCH] tdf#160770: use OUString ctor that takes length, which allows nullptr bstrDescription can obviously be nullptr. Change-Id: I09f368a632143479c165cb0653a33aef26fe0e95 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180743 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- extensions/source/ole/oleobjw.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/extensions/source/ole/oleobjw.cxx b/extensions/source/ole/oleobjw.cxx index d9c0296110fd..e3e5c23357f5 100644 --- a/extensions/source/ole/oleobjw.cxx +++ b/extensions/source/ole/oleobjw.cxx @@ -430,6 +430,8 @@ void SAL_CALL IUnknownWrapper::setValue( const OUString& aPropertyName, } } +static OUString BStrToOUString(BSTR s) { return OUString(o3tl::toU(s), SysStringLen(s)); } + Any SAL_CALL IUnknownWrapper::getValue( const OUString& aPropertyName ) { if ( ! m_spDispatch ) @@ -539,13 +541,13 @@ Any SAL_CALL IUnknownWrapper::getValue( const OUString& aPropertyName ) case DISP_E_BADPARAMCOUNT: case DISP_E_BADVARTYPE: case DISP_E_EXCEPTION: - throw RuntimeException(OUString(o3tl::toU(excepinfo.bstrDescription))); + throw RuntimeException(BStrToOUString(excepinfo.bstrDescription)); break; case DISP_E_MEMBERNOTFOUND: - throw UnknownPropertyException(OUString(o3tl::toU(excepinfo.bstrDescription))); + throw UnknownPropertyException(BStrToOUString(excepinfo.bstrDescription)); break; default: - throw RuntimeException(OUString(o3tl::toU(excepinfo.bstrDescription))); + throw RuntimeException(BStrToOUString(excepinfo.bstrDescription)); break; } }