diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-03-06 16:06:40 +0600 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-03-11 04:43:28 +0100 |
commit | 1ac5353bbb25bd9ff0ab0e157b3dbd0da325480a (patch) | |
tree | 540dc6574b0d1b2e67afee3d670b8805493f28fa /oox | |
parent | e2bfc34d146806a8f96be0cd2323d716f12cba4e (diff) |
Use weak reference to SfxObjectShell in SfxEventHint to avoid use-after-free
The events may be processed after the shell has been destroyed. This is
happening reliably after commit e2bfc34d146806a8f96be0cd2323d716f12cba4e
(Reimplement OleComponentNative_Impl to use IGlobalInterfaceTable,
2024-03-11) when controlling LibreOffice from external Java scripts; but
obviously, it could happen before as well.
Now SotObject inherits from cppu::OWeakObject, instead of SvRefBase.
Change-Id: I73a3531499a3068c801c98f40de39bdf8ad90b2b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164458
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/ole/olehelper.cxx | 18 | ||||
-rw-r--r-- | oox/source/ole/vbaexport.cxx | 12 |
2 files changed, 15 insertions, 15 deletions
diff --git a/oox/source/ole/olehelper.cxx b/oox/source/ole/olehelper.cxx index d953cf17f9da..e5a81320156b 100644 --- a/oox/source/ole/olehelper.cxx +++ b/oox/source/ole/olehelper.cxx @@ -437,7 +437,7 @@ MSConvertOCXControls::importControlFromStream( ::oox::BinaryInputStream& rInStrm } bool -MSConvertOCXControls::ReadOCXCtlsStream( tools::SvRef<SotStorageStream> const & rSrc1, Reference< XFormComponent > & rxFormComp, +MSConvertOCXControls::ReadOCXCtlsStream( rtl::Reference<SotStorageStream> const & rSrc1, Reference< XFormComponent > & rxFormComp, sal_Int32 nPos, sal_Int32 nStreamSize) { @@ -486,18 +486,18 @@ bool MSConvertOCXControls::importControlFromStream( ::oox::BinaryInputStream& rI return rxFormComp.is(); } -bool MSConvertOCXControls::ReadOCXStorage( tools::SvRef<SotStorage> const & xOleStg, +bool MSConvertOCXControls::ReadOCXStorage( rtl::Reference<SotStorage> const & xOleStg, Reference< XFormComponent > & rxFormComp ) { if ( xOleStg.is() ) { - tools::SvRef<SotStorageStream> pNameStream = xOleStg->OpenSotStream("\3OCXNAME", StreamMode::READ); + rtl::Reference<SotStorageStream> pNameStream = xOleStg->OpenSotStream("\3OCXNAME", StreamMode::READ); BinaryXInputStream aNameStream( Reference< XInputStream >( new utl::OSeekableInputStreamWrapper( *pNameStream ) ), true ); - tools::SvRef<SotStorageStream> pContents = xOleStg->OpenSotStream("contents", StreamMode::READ); + rtl::Reference<SotStorageStream> pContents = xOleStg->OpenSotStream("contents", StreamMode::READ); BinaryXInputStream aInStrm( Reference< XInputStream >( new utl::OSeekableInputStreamWrapper( *pContents ) ), true ); - tools::SvRef<SotStorageStream> pClsStrm = xOleStg->OpenSotStream("\1CompObj", StreamMode::READ); + rtl::Reference<SotStorageStream> pClsStrm = xOleStg->OpenSotStream("\1CompObj", StreamMode::READ); BinaryXInputStream aClsStrm( Reference< XInputStream >( new utl::OSeekableInputStreamWrapper(*pClsStrm ) ), true ); aClsStrm.skip(12); @@ -533,7 +533,7 @@ bool MSConvertOCXControls::WriteOCXExcelKludgeStream( const css::uno::Reference< return true; } -bool MSConvertOCXControls::WriteOCXStream( const Reference< XModel >& rxModel, tools::SvRef<SotStorage> const &xOleStg, +bool MSConvertOCXControls::WriteOCXStream( const Reference< XModel >& rxModel, rtl::Reference<SotStorage> const &xOleStg, const Reference< XControlModel > &rxControlModel, const css::awt::Size& rSize, OUString &rName) { @@ -550,17 +550,17 @@ bool MSConvertOCXControls::WriteOCXStream( const Reference< XModel >& rxModel, t rName = exportHelper.getTypeName(); xOleStg->SetClass( aName, SotClipboardFormatId::EMBEDDED_OBJ_OLE, sFullName); { - tools::SvRef<SotStorageStream> pNameStream = xOleStg->OpenSotStream("\3OCXNAME"); + rtl::Reference<SotStorageStream> pNameStream = xOleStg->OpenSotStream("\3OCXNAME"); Reference< XOutputStream > xOut = new utl::OSeekableOutputStreamWrapper( *pNameStream ); exportHelper.exportName( xOut ); } { - tools::SvRef<SotStorageStream> pObjStream = xOleStg->OpenSotStream("\1CompObj"); + rtl::Reference<SotStorageStream> pObjStream = xOleStg->OpenSotStream("\1CompObj"); Reference< XOutputStream > xOut = new utl::OSeekableOutputStreamWrapper( *pObjStream ); exportHelper.exportCompObj( xOut ); } { - tools::SvRef<SotStorageStream> pContents = xOleStg->OpenSotStream("contents"); + rtl::Reference<SotStorageStream> pContents = xOleStg->OpenSotStream("contents"); Reference< XOutputStream > xOut = new utl::OSeekableOutputStreamWrapper( *pContents ); exportHelper.exportControl( xOut, rSize ); } diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx index c59895246a09..44657ebc3408 100644 --- a/oox/source/ole/vbaexport.cxx +++ b/oox/source/ole/vbaexport.cxx @@ -1040,12 +1040,12 @@ void VbaExport::exportVBA(SotStorage* pRootStorage) getCorrectExportOrder(xNameContainer, aLibraryMap); // start here with the VBA export - tools::SvRef<SotStorage> xVBAStream = pRootStorage->OpenSotStorage("VBA", StreamMode::READWRITE); - tools::SvRef<SotStorageStream> pDirStream = xVBAStream->OpenSotStream("dir", StreamMode::READWRITE); + rtl::Reference<SotStorage> xVBAStream = pRootStorage->OpenSotStorage("VBA", StreamMode::READWRITE); + rtl::Reference<SotStorageStream> pDirStream = xVBAStream->OpenSotStream("dir", StreamMode::READWRITE); - tools::SvRef<SotStorageStream> pVBAProjectStream = xVBAStream->OpenSotStream("_VBA_PROJECT", StreamMode::READWRITE); - tools::SvRef<SotStorageStream> pPROJECTStream = pRootStorage->OpenSotStream("PROJECT", StreamMode::READWRITE); - tools::SvRef<SotStorageStream> pPROJECTwmStream = pRootStorage->OpenSotStream("PROJECTwm", StreamMode::READWRITE); + rtl::Reference<SotStorageStream> pVBAProjectStream = xVBAStream->OpenSotStream("_VBA_PROJECT", StreamMode::READWRITE); + rtl::Reference<SotStorageStream> pPROJECTStream = pRootStorage->OpenSotStream("PROJECT", StreamMode::READWRITE); + rtl::Reference<SotStorageStream> pPROJECTwmStream = pRootStorage->OpenSotStream("PROJECTwm", StreamMode::READWRITE); const rtl_TextEncoding eTextEncoding = getVBATextEncoding(); @@ -1106,7 +1106,7 @@ void VbaExport::exportVBA(SotStorage* pRootStorage) for (sal_Int32 i = 0; i < n; ++i) { const OUString& rModuleName = aElementNames[aLibraryMap[i]]; - tools::SvRef<SotStorageStream> pModuleStream = xVBAStream->OpenSotStream(rModuleName, StreamMode::READWRITE); + rtl::Reference<SotStorageStream> pModuleStream = xVBAStream->OpenSotStream(rModuleName, StreamMode::READWRITE); css::uno::Any aCode = xNameContainer->getByName(rModuleName); css::script::ModuleInfo aModuleInfo = xModuleInfo->getModuleInfo(rModuleName); OUString aSourceCode; |