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 /sw/source/uibase/uno/unotxvw.cxx | |
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 'sw/source/uibase/uno/unotxvw.cxx')
-rw-r--r-- | sw/source/uibase/uno/unotxvw.cxx | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sw/source/uibase/uno/unotxvw.cxx b/sw/source/uibase/uno/unotxvw.cxx index a859e4ec5657..fd6e6fdf8bb6 100644 --- a/sw/source/uibase/uno/unotxvw.cxx +++ b/sw/source/uibase/uno/unotxvw.cxx @@ -604,8 +604,8 @@ SfxObjectShellLock SwXTextView::BuildTmpSelectionDoc() { SwWrtShell& rOldSh = m_pView->GetWrtShell(); SfxPrinter *pPrt = rOldSh.getIDocumentDeviceAccess().getPrinter( false ); - SwDocShell* pDocSh; - SfxObjectShellLock xDocSh( pDocSh = new SwDocShell(SfxObjectCreateMode::STANDARD) ); + rtl::Reference<SwDocShell> pDocSh = new SwDocShell(SfxObjectCreateMode::STANDARD); + SfxObjectShellLock xDocSh(pDocSh.get()); xDocSh->DoInitNew(); SwDoc *const pTempDoc( pDocSh->GetDoc() ); // #i103634#, #i112425#: do not expand numbering and fields on PDF export |