diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-03-27 12:36:25 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2022-05-17 15:47:05 +0200 |
commit | b8598ebb616ccf3b0b14424bb5193d2dbb8f4ac8 (patch) | |
tree | 8aa3478f166d702a4cf494f3d1d38d2ec43ea56e | |
parent | forcepoint#90 fix crash on layout of specific rtf (diff) | |
download | core-b8598ebb616ccf3b0b14424bb5193d2dbb8f4ac8.tar.gz core-b8598ebb616ccf3b0b14424bb5193d2dbb8f4ac8.zip |
forcepoint#93 fix crash on layout of specific rtf
Change-Id: Id81729de2efd6f65f1b51bdb437ca21a260eaf6e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133481
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit 5277b953b29845555cba8f867c9c750e8bc510a5)
-rw-r--r-- | sw/qa/extras/layout/data/forcepoint93-1.rtf | bin | 0 -> 88310 bytes | |||
-rw-r--r-- | sw/qa/extras/layout/data/forcepoint93-2.rtf | bin | 0 -> 5456 bytes | |||
-rw-r--r-- | sw/qa/extras/layout/layout.cxx | 7 | ||||
-rw-r--r-- | sw/source/core/inc/frame.hxx | 11 | ||||
-rw-r--r-- | sw/source/core/layout/objectformattertxtfrm.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/layout/wsfrm.cxx | 2 |
6 files changed, 15 insertions, 7 deletions
diff --git a/sw/qa/extras/layout/data/forcepoint93-1.rtf b/sw/qa/extras/layout/data/forcepoint93-1.rtf Binary files differnew file mode 100644 index 000000000000..bbe5ecfb78f2 --- /dev/null +++ b/sw/qa/extras/layout/data/forcepoint93-1.rtf diff --git a/sw/qa/extras/layout/data/forcepoint93-2.rtf b/sw/qa/extras/layout/data/forcepoint93-2.rtf Binary files differnew file mode 100644 index 000000000000..bcc5f3dc8855 --- /dev/null +++ b/sw/qa/extras/layout/data/forcepoint93-2.rtf diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index a3acf5af69b0..bd0e1b07223a 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -2316,6 +2316,13 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint90) //just care it doesn't crash/assert CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint92) { createDoc("forcepoint92.doc"); } +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint93) +{ +//fails to load createDoc("forcepoint93-1.rtf"); + createDoc("forcepoint93-2.rtf"); +} + #if 0 // no createSwWebDoc //just care it doesn't crash/assert CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint94) diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx index 90930daeabee..f27f5f73a4eb 100644 --- a/sw/source/core/inc/frame.hxx +++ b/sw/source/core/inc/frame.hxx @@ -427,7 +427,7 @@ protected: bool mbColLocked : 1; // lock Grow/Shrink for column-wise section // or fly frames, will be set in Format bool m_isInDestroy : 1; - bool mbForbidDelete : 1; + int mnForbidDelete; void ColLock() { mbColLocked = true; } void ColUnlock() { mbColLocked = false; } @@ -865,7 +865,7 @@ public: bool IsProtected() const; bool IsColLocked() const { return mbColLocked; } - virtual bool IsDeleteForbidden() const { return mbForbidDelete; } + virtual bool IsDeleteForbidden() const { return mnForbidDelete > 0; } /// this is the only way to delete a SwFrame instance static void DestroyFrame(SwFrame *const pFrame); @@ -905,8 +905,8 @@ public: void RegisterToFormat( SwFormat& rFormat ); void ValidateThisAndAllLowers( const sal_uInt16 nStage ); - void ForbidDelete() { mbForbidDelete = true; } - void AllowDelete() { mbForbidDelete = false; } + void ForbidDelete() { ++mnForbidDelete; } + void AllowDelete() { assert(mnForbidDelete > 0); --mnForbidDelete; } drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const; bool supportsFullDrawingLayerFillAttributeSet() const; @@ -1243,8 +1243,7 @@ public: //it in e.g. SwSectionFrame::MergeNext etc because we will need it //again after the SwFrameDeleteGuard dtor explicit SwFrameDeleteGuard(SwFrame* pFrame) - : m_pForbidFrame((pFrame && !pFrame->IsDeleteForbidden()) ? - pFrame : nullptr) + : m_pForbidFrame(pFrame) { if (m_pForbidFrame) m_pForbidFrame->ForbidDelete(); diff --git a/sw/source/core/layout/objectformattertxtfrm.cxx b/sw/source/core/layout/objectformattertxtfrm.cxx index 0ad6178fac1b..a5752e07e2f1 100644 --- a/sw/source/core/layout/objectformattertxtfrm.cxx +++ b/sw/source/core/layout/objectformattertxtfrm.cxx @@ -881,6 +881,8 @@ void SwObjectFormatterTextFrame::FormatAnchorFrameAndItsPrevs( SwTextFrame& _rAn // Thus, check for valid <pFrame>. while ( pFrame && pFrame != pSectFrame ) { + SwFrameDeleteGuard aDeleteFrameGuard(pFrame); + if ( pFrame->IsLayoutFrame() ) lcl_FormatContentOfLayoutFrame( static_cast<SwLayoutFrame*>(pFrame) ); else diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx index 184ee0d6c9a8..2259c44871fb 100644 --- a/sw/source/core/layout/wsfrm.cxx +++ b/sw/source/core/layout/wsfrm.cxx @@ -319,7 +319,7 @@ SwFrame::SwFrame( sw::BroadcastingModify *pMod, SwFrame* pSib ) mbInfSct ( false ), mbColLocked(false), m_isInDestroy(false), - mbForbidDelete(false) + mnForbidDelete(0) { OSL_ENSURE( pMod, "No frame format given." ); } |