From 5e18136a01208f5df7c5f554bbcdab2ef661e136 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Thu, 22 Mar 2018 21:18:56 +0100 Subject: [PATCH] forcepoint #3: sw: don't do section-in-table splits when this is table The problem with the bugdoc is that SwFrame::GetNextSctLeaf() creates a follow frame for a section in a table, and puts it outside the table, below the page's body frame, while moving text frames that have the mbInfTab flag set into the follow frame. The situation is different from forcepoint #18 though: the frame "this" is a SwTabFrame here, and GetNextCellLeaf() *does* return a plausible looking follow cell frame, however it's ignored later because CanContainSplitSection(this) is false since it's a SwTabFrame. IIRC table-in-section-in-table should not be split anyway, so just add a check here and return early. (regression f8a76d218305a56d15b82b9dac4fafa558872780) Revert "forcepoint #3" This reverts commit 34627ad7d03f93b89689b2e48a3985574d10f965 because it was just a work-around not to crash with the invalid table frames. Change-Id: I54692a67edade23c6b8e0a9be806728b0012a3fd Reviewed-on: https://gerrit.libreoffice.org/51751 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- .../data/flowframe_null_ptr_deref.sample | 654 ++++++++++++++++++ sw/qa/extras/uiwriter/uiwriter.cxx | 15 + sw/source/core/layout/ftnfrm.cxx | 13 +- sw/source/core/layout/sectfrm.cxx | 4 + 4 files changed, 681 insertions(+), 5 deletions(-) create mode 100644 sw/qa/extras/uiwriter/data/flowframe_null_ptr_deref.sample diff --git a/sw/qa/extras/uiwriter/data/flowframe_null_ptr_deref.sample b/sw/qa/extras/uiwriter/data/flowframe_null_ptr_deref.sample new file mode 100644 index 000000000000..ec4e8423a08a --- /dev/null +++ b/sw/qa/extras/uiwriter/data/flowframe_null_ptr_deref.sample @@ -0,0 +1,654 @@ + + + + + + + + + + KDE::Enterprise Homepage - Business Directory + + + + + + + + + + + + + + + + + KDE::Enterprise Homepage - Business Directory + + + + + + + + + + + + + + + + + KDE::Enterprise Homepage - Business Directory + + + + + + + + + + + + + + + + + KDE::Enterprise Homepage - Business Directory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+
 
+ +
+ + +

Business Directory

+ +

A problem has been detected with your submisson

+

In the Business Name box you did not enter a valid name.

+

Please correct the problem below and resubmit.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
--> Business Name + +
Contact Name + +
Email Address + + Publish e-mail address
Website + +
Address + +
+ +
+ +

+ If more than one address, please add your head office. +

Postcode / Zip Code + +
Country + +
Phone Number + +
Fax Number + +
Business Services + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
On Site Support
Phone Support
Distribution
Free software development
Commercial development
Consulting
Retail
Other + +
+
Comments + +
+ + +
+
+

+ Back to the Business Directory +

+ + +
+ +

Inform

+ +

KDE::Enterprise

+ + + + + + + +
+ +
+ + diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index f16dec2a61a4..5b97e54f6867 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -175,6 +175,7 @@ public: void testDeleteTableRedlines(); void testXFlatParagraph(); void testTdf81995(); + void testForcepoint3(); void testExportToPicture(); void testTdf77340(); void testTdf79236(); @@ -360,6 +361,7 @@ public: CPPUNIT_TEST(testDeleteTableRedlines); CPPUNIT_TEST(testXFlatParagraph); CPPUNIT_TEST(testTdf81995); + CPPUNIT_TEST(testForcepoint3); CPPUNIT_TEST(testExportToPicture); CPPUNIT_TEST(testTdf77340); CPPUNIT_TEST(testTdf79236); @@ -1901,6 +1903,19 @@ void SwUiWriterTest::testTdf81995() } } +void SwUiWriterTest::testForcepoint3() +{ + createDoc("flowframe_null_ptr_deref.sample"); + uno::Sequence aDescriptor( comphelper::InitPropertySequence({ + { "FilterName", uno::Any(OUString("writer_pdf_Export")) }, + })); + utl::TempFile aTempFile; + uno::Reference xStorable(mxComponent, uno::UNO_QUERY); + // printing asserted in SwFrame::GetNextSctLeaf() + xStorable->storeToURL(aTempFile.GetURL(), aDescriptor); + aTempFile.EnableKillingFile(); +} + void SwUiWriterTest::testExportToPicture() { createDoc(); diff --git a/sw/source/core/layout/ftnfrm.cxx b/sw/source/core/layout/ftnfrm.cxx index 206e9deac04e..e8eddce278c1 100644 --- a/sw/source/core/layout/ftnfrm.cxx +++ b/sw/source/core/layout/ftnfrm.cxx @@ -792,11 +792,14 @@ bool SwFrame::IsFootnoteAllowed() const if ( !IsInDocBody() ) return false; - // no footnotes in repeated headlines - const SwTabFrame *pTab = IsInTab() ? const_cast(this)->ImplFindTabFrame() : nullptr; - if (pTab && pTab->IsFollow()) - return !pTab->IsInHeadline( *this ); - + if ( IsInTab() ) + { + // no footnotes in repeated headlines + const SwTabFrame *pTab = const_cast(this)->ImplFindTabFrame(); + assert(pTab); + if ( pTab->IsFollow() ) + return !pTab->IsInHeadline( *this ); + } return true; } diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx index ce3c2017ace0..8f68adf082c7 100644 --- a/sw/source/core/layout/sectfrm.cxx +++ b/sw/source/core/layout/sectfrm.cxx @@ -1614,6 +1614,10 @@ SwLayoutFrame *SwFrame::GetNextSctLeaf( MakePageType eMakePage ) SwLayoutFrame* pCellLeaf = nullptr; if (GetUpper()->IsInTab()) { + if (IsTabFrame()) + { + return nullptr; // table in section in table: split disabled for now + } // We are *in* a table (not an outermost SwTabFrame), see if there // is a follow cell frame created already. pCellLeaf = GetNextCellLeaf();