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 /starmath/source | |
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 'starmath/source')
-rw-r--r-- | starmath/source/document.cxx | 2 | ||||
-rw-r--r-- | starmath/source/eqnolefilehdr.cxx | 2 | ||||
-rw-r--r-- | starmath/source/mathtype.cxx | 10 | ||||
-rw-r--r-- | starmath/source/smdetect.cxx | 2 | ||||
-rw-r--r-- | starmath/source/unodoc.cxx | 2 | ||||
-rw-r--r-- | starmath/source/unofilter.cxx | 2 |
6 files changed, 10 insertions, 10 deletions
diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx index 6da2c96e4265..0f15e6049015 100644 --- a/starmath/source/document.cxx +++ b/starmath/source/document.cxx @@ -638,7 +638,7 @@ bool SmDocShell::ConvertFrom(SfxMedium &rMedium) { if ( SotStorage::IsStorageFile( pStream ) ) { - tools::SvRef<SotStorage> aStorage = new SotStorage( pStream, false ); + rtl::Reference<SotStorage> aStorage = new SotStorage(pStream, false); if ( aStorage->IsStream("Equation Native") ) { // is this a MathType Storage? diff --git a/starmath/source/eqnolefilehdr.cxx b/starmath/source/eqnolefilehdr.cxx index f211f1aaa942..d178e3d072c0 100644 --- a/starmath/source/eqnolefilehdr.cxx +++ b/starmath/source/eqnolefilehdr.cxx @@ -29,7 +29,7 @@ bool GetMathTypeVersion( SotStorage* pStor, sal_uInt8 &nVersion ) // code snippet copied from MathType::Parse - tools::SvRef<SotStorageStream> xSrc = pStor->OpenSotStream( + rtl::Reference<SotStorageStream> xSrc = pStor->OpenSotStream( "Equation Native", StreamMode::STD_READ); if ( (!xSrc.is()) || (ERRCODE_NONE != xSrc->GetError())) diff --git a/starmath/source/mathtype.cxx b/starmath/source/mathtype.cxx index aca49f034ad0..8ebef375cb8c 100644 --- a/starmath/source/mathtype.cxx +++ b/starmath/source/mathtype.cxx @@ -549,7 +549,7 @@ void MathType::TypeFaceToString(OUString &rTxt,sal_uInt8 nFace) bool MathType::Parse(SotStorage *pStor) { - tools::SvRef<SotStorageStream> xSrc = pStor->OpenSotStream( + rtl::Reference<SotStorageStream> xSrc = pStor->OpenSotStream( "Equation Native", StreamMode::STD_READ); if ( (!xSrc.is()) || (ERRCODE_NONE != xSrc->GetError())) @@ -1869,7 +1869,7 @@ bool MathType::ConvertFromStarMath( SfxMedium& rMedium ) SvStream *pStream = rMedium.GetOutStream(); if ( pStream ) { - tools::SvRef<SotStorage> pStor = new SotStorage( pStream, false ); + rtl::Reference<SotStorage> pStor = new SotStorage(pStream, false); SvGlobalName aGName(MSO_EQUATION3_CLASSID); pStor->SetClass( aGName, SotClipboardFormatId::NONE, "Microsoft Equation 3.0"); @@ -1889,7 +1889,7 @@ bool MathType::ConvertFromStarMath( SfxMedium& rMedium ) 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - tools::SvRef<SotStorageStream> xStor( pStor->OpenSotStream("\1CompObj")); + rtl::Reference<SotStorageStream> xStor(pStor->OpenSotStream("\1CompObj")); xStor->WriteBytes(aCompObj, sizeof(aCompObj)); static sal_uInt8 const aOle[] = { @@ -1897,12 +1897,12 @@ bool MathType::ConvertFromStarMath( SfxMedium& rMedium ) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - tools::SvRef<SotStorageStream> xStor2( pStor->OpenSotStream("\1Ole")); + rtl::Reference<SotStorageStream> xStor2(pStor->OpenSotStream("\1Ole")); xStor2->WriteBytes(aOle, sizeof(aOle)); xStor.clear(); xStor2.clear(); - tools::SvRef<SotStorageStream> xSrc = pStor->OpenSotStream("Equation Native"); + rtl::Reference<SotStorageStream> xSrc = pStor->OpenSotStream("Equation Native"); if ( (!xSrc.is()) || (ERRCODE_NONE != xSrc->GetError())) return false; diff --git a/starmath/source/smdetect.cxx b/starmath/source/smdetect.cxx index 80231c21b7fe..825186bb08d4 100644 --- a/starmath/source/smdetect.cxx +++ b/starmath/source/smdetect.cxx @@ -71,7 +71,7 @@ OUString SAL_CALL SmFilterDetect::detect( Sequence< PropertyValue >& lDescriptor bool bStorageOk = false; try { - tools::SvRef<SotStorage> aStorage = new SotStorage( pInStrm, false ); + rtl::Reference<SotStorage> aStorage = new SotStorage(pInStrm, false); bStorageOk = !aStorage->GetError(); if (bStorageOk) { diff --git a/starmath/source/unodoc.cxx b/starmath/source/unodoc.cxx index 3c125077c402..5eaab9cdc412 100644 --- a/starmath/source/unodoc.cxx +++ b/starmath/source/unodoc.cxx @@ -35,7 +35,7 @@ Math_FormulaDocument_get_implementation( css::uno::Reference<css::uno::XInterface> xInterface = sfx2::createSfxModelInstance(args, [](SfxModelFlags _nCreationFlags) { - SfxObjectShell* pShell = new SmDocShell( _nCreationFlags ); + rtl::Reference<SfxObjectShell> pShell = new SmDocShell(_nCreationFlags); return pShell->GetModel(); }); xInterface->acquire(); diff --git a/starmath/source/unofilter.cxx b/starmath/source/unofilter.cxx index 0b73175b003b..568e4e6e683d 100644 --- a/starmath/source/unofilter.cxx +++ b/starmath/source/unofilter.cxx @@ -60,7 +60,7 @@ sal_Bool MathTypeFilter::filter(const uno::Sequence<beans::PropertyValue>& rDesc { if (SotStorage::IsStorageFile(pStream.get())) { - tools::SvRef<SotStorage> aStorage(new SotStorage(pStream.get(), false)); + rtl::Reference<SotStorage> aStorage(new SotStorage(pStream.get(), false)); // Is this a MathType Storage? if (aStorage->IsStream("Equation Native")) { |