summaryrefslogtreecommitdiff
path: root/sw/inc
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 /sw/inc
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 'sw/inc')
-rw-r--r--sw/inc/doc.hxx2
-rw-r--r--sw/inc/shellio.hxx10
2 files changed, 6 insertions, 6 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index d9dde916b798..e359cb0ba293 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1657,7 +1657,7 @@ public:
SW_DLLPUBLIC ::sw::UndoManager & GetUndoManager();
::sw::UndoManager const& GetUndoManager() const;
- SfxObjectShell* CreateCopy(bool bCallInitNew, bool bEmpty) const;
+ rtl::Reference<SfxObjectShell> CreateCopy(bool bCallInitNew, bool bEmpty) const;
SwNodeIndex AppendDoc(const SwDoc& rSource, sal_uInt16 nStartPageNumber,
bool bDeletePrevious, int physicalPageOffset,
const sal_uLong nDocNo);
diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx
index c9fc67ea378e..d802cc80d446 100644
--- a/sw/inc/shellio.hxx
+++ b/sw/inc/shellio.hxx
@@ -146,7 +146,7 @@ public:
class SW_DLLPUBLIC SwReader: public SwDocFac
{
SvStream* mpStrm;
- tools::SvRef<SotStorage> mpStg;
+ rtl::Reference<SotStorage> mpStg;
css::uno::Reference < css::embed::XStorage > mxStg;
SfxMedium* mpMedium; // Who wants to obtain a Medium (W4W).
@@ -213,7 +213,7 @@ class SW_DLLPUBLIC Reader
protected:
SvStream* m_pStream;
- tools::SvRef<SotStorage> m_pStorage;
+ rtl::Reference<SotStorage> m_pStorage;
css::uno::Reference < css::embed::XStorage > m_xStorage;
SfxMedium* m_pMedium; // Who wants to obtain a Medium (W4W).
@@ -271,8 +271,8 @@ public:
virtual size_t GetSectionList( SfxMedium& rMedium,
std::vector<OUString>& rStrings) const;
- const tools::SvRef<SotStorage>& getSotStorageRef() const { return m_pStorage; };
- void setSotStorageRef(const tools::SvRef<SotStorage>& pStgRef) { m_pStorage = pStgRef; };
+ const rtl::Reference<SotStorage>& getSotStorageRef() const { return m_pStorage; };
+ void setSotStorageRef(const rtl::Reference<SotStorage>& pStgRef) { m_pStorage = pStgRef; };
private:
virtual ErrCodeMsg Read(SwDoc &, const OUString& rBaseURL, SwPaM &, const OUString &)=0;
@@ -475,7 +475,7 @@ typedef tools::SvRef<Writer> WriterRef;
class SW_DLLPUBLIC StgWriter : public Writer
{
protected:
- tools::SvRef<SotStorage> m_pStg;
+ rtl::Reference<SotStorage> m_pStg;
css::uno::Reference < css::embed::XStorage > m_xStg;
// Create error at call.