sw/qa/extras/layout/data/forcepoint93-1.rtf |binary sw/qa/extras/layout/data/forcepoint93-2.rtf |binary sw/qa/extras/layout/layout.cxx | 7 +++++++ sw/source/core/inc/frame.hxx | 11 +++++------ sw/source/core/layout/objectformattertxtfrm.cxx | 2 ++ sw/source/core/layout/wsfrm.cxx | 2 +- 6 files changed, 15 insertions(+), 7 deletions(-)
New commits: commit 5277b953b29845555cba8f867c9c750e8bc510a5 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Sun Mar 27 12:36:25 2022 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Thu Apr 28 10:30:21 2022 +0200 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.st...@allotropia.de> diff --git a/sw/qa/extras/layout/data/forcepoint93-1.rtf b/sw/qa/extras/layout/data/forcepoint93-1.rtf new file mode 100644 index 000000000000..bbe5ecfb78f2 Binary files /dev/null and b/sw/qa/extras/layout/data/forcepoint93-1.rtf differ diff --git a/sw/qa/extras/layout/data/forcepoint93-2.rtf b/sw/qa/extras/layout/data/forcepoint93-2.rtf new file mode 100644 index 000000000000..bcc5f3dc8855 Binary files /dev/null and b/sw/qa/extras/layout/data/forcepoint93-2.rtf differ diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index c78273685865..4122d3725b88 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -2523,6 +2523,13 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint92) createSwDoc(DATA_DIRECTORY, "forcepoint92.doc"); } +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint93) +{ + createSwDoc(DATA_DIRECTORY, "forcepoint93-1.rtf"); + createSwDoc(DATA_DIRECTORY, "forcepoint93-2.rtf"); +} + //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 3b1414002140..f634b7280f73 100644 --- a/sw/source/core/inc/frame.hxx +++ b/sw/source/core/inc/frame.hxx @@ -444,7 +444,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; } @@ -885,7 +885,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); @@ -925,8 +925,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; @@ -1263,8 +1263,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 d0fa8cf1be84..2fb0ced81291 100644 --- a/sw/source/core/layout/objectformattertxtfrm.cxx +++ b/sw/source/core/layout/objectformattertxtfrm.cxx @@ -879,6 +879,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 294ce00ffff3..62c99a5f6e87 100644 --- a/sw/source/core/layout/wsfrm.cxx +++ b/sw/source/core/layout/wsfrm.cxx @@ -317,7 +317,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." ); }