summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2024-03-06 16:06:40 +0600
committerMike Kaganski <mike.kaganski@collabora.com>2024-03-11 04:43:28 +0100
commit1ac5353bbb25bd9ff0ab0e157b3dbd0da325480a (patch)
tree540dc6574b0d1b2e67afee3d670b8805493f28fa /starmath
parente2bfc34d146806a8f96be0cd2323d716f12cba4e (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')
-rw-r--r--starmath/qa/cppunit/test_cursor.cxx2
-rw-r--r--starmath/qa/cppunit/test_node.cxx2
-rw-r--r--starmath/qa/cppunit/test_nodetotextvisitors.cxx2
-rw-r--r--starmath/qa/cppunit/test_parse.cxx2
-rw-r--r--starmath/qa/cppunit/test_starmath.cxx2
-rw-r--r--starmath/source/document.cxx2
-rw-r--r--starmath/source/eqnolefilehdr.cxx2
-rw-r--r--starmath/source/mathtype.cxx10
-rw-r--r--starmath/source/smdetect.cxx2
-rw-r--r--starmath/source/unodoc.cxx2
-rw-r--r--starmath/source/unofilter.cxx2
11 files changed, 15 insertions, 15 deletions
diff --git a/starmath/qa/cppunit/test_cursor.cxx b/starmath/qa/cppunit/test_cursor.cxx
index 12e63626eee3..002a445745c9 100644
--- a/starmath/qa/cppunit/test_cursor.cxx
+++ b/starmath/qa/cppunit/test_cursor.cxx
@@ -21,7 +21,7 @@
#include <memory>
-typedef tools::SvRef<SmDocShell> SmDocShellRef;
+typedef rtl::Reference<SmDocShell> SmDocShellRef;
using namespace ::com::sun::star;
diff --git a/starmath/qa/cppunit/test_node.cxx b/starmath/qa/cppunit/test_node.cxx
index acb1c27d4c79..7b42056fb35e 100644
--- a/starmath/qa/cppunit/test_node.cxx
+++ b/starmath/qa/cppunit/test_node.cxx
@@ -26,7 +26,7 @@ namespace {
using namespace ::com::sun::star;
-typedef tools::SvRef<SmDocShell> SmDocShellRef;
+typedef rtl::Reference<SmDocShell> SmDocShellRef;
class NodeTest : public test::BootstrapFixture
{
diff --git a/starmath/qa/cppunit/test_nodetotextvisitors.cxx b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
index 1b8c0292ba31..d4981445d8bb 100644
--- a/starmath/qa/cppunit/test_nodetotextvisitors.cxx
+++ b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
@@ -23,7 +23,7 @@
#include "mock-visitor.hxx"
#include <memory>
-typedef tools::SvRef<SmDocShell> SmDocShellRef;
+typedef rtl::Reference<SmDocShell> SmDocShellRef;
using namespace ::com::sun::star;
diff --git a/starmath/qa/cppunit/test_parse.cxx b/starmath/qa/cppunit/test_parse.cxx
index 2171cde80e56..cb158a15491d 100644
--- a/starmath/qa/cppunit/test_parse.cxx
+++ b/starmath/qa/cppunit/test_parse.cxx
@@ -23,7 +23,7 @@ namespace {
using namespace ::com::sun::star;
-typedef tools::SvRef<SmDocShell> SmDocShellRef;
+typedef rtl::Reference<SmDocShell> SmDocShellRef;
class ParseTest : public test::BootstrapFixture
{
diff --git a/starmath/qa/cppunit/test_starmath.cxx b/starmath/qa/cppunit/test_starmath.cxx
index 60eb85944571..79b1bd461181 100644
--- a/starmath/qa/cppunit/test_starmath.cxx
+++ b/starmath/qa/cppunit/test_starmath.cxx
@@ -31,7 +31,7 @@
#include <starmath.hrc>
#include <memory>
-typedef tools::SvRef<SmDocShell> SmDocShellRef;
+typedef rtl::Reference<SmDocShell> SmDocShellRef;
using namespace ::com::sun::star;
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"))
{