diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2023-06-01 20:19:36 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2023-06-02 17:18:41 +0200 |
commit | 710af7d183370ca6fdd2699ea9f4550d9e53918a (patch) | |
tree | e6e6c98e5d3350a108340d8940d11d25ebca6f30 | |
parent | 69a3bcdaa54700a372151af52ccfbb0deed9db45 (diff) |
tdf#152983 sw: layout: fix crash in SwContentFrame::Cut()
Surprisingly, SwContentFrame::Cut() is called in a situation where the
frame is not connected to any SwPageFrame yet - it is in a follow fly of
a fly chain that is anchored in a footer, and SwFlyFrame::ChainFrames()
removes it.
(regression from commit b9ef71476fd70bc13f50ebe80390e0730d1b7afb)
Change-Id: Iad84b7b422126e050493dc3b181d47c4dca2fae2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152510
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r-- | sw/qa/extras/layout/data/tdf152983-1-min.docx | bin | 0 -> 100691 bytes | |||
-rw-r--r-- | sw/qa/extras/layout/layout.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/layout/wsfrm.cxx | 5 |
3 files changed, 9 insertions, 2 deletions
diff --git a/sw/qa/extras/layout/data/tdf152983-1-min.docx b/sw/qa/extras/layout/data/tdf152983-1-min.docx Binary files differnew file mode 100644 index 000000000000..804e8fefe68f --- /dev/null +++ b/sw/qa/extras/layout/data/tdf152983-1-min.docx diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index e985c62626a5..995c6ddfc7a6 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -1210,6 +1210,12 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf150606) } #endif +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf152983) +{ + //just care it doesn't crash/assert + createSwDoc("tdf152983-1-min.docx"); +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf137025) { // Check the padding of the textbox diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx index e30e3ecc401a..2834b09f70a6 100644 --- a/sw/source/core/layout/wsfrm.cxx +++ b/sw/source/core/layout/wsfrm.cxx @@ -1232,10 +1232,11 @@ void SwContentFrame::Cut() // RemoveSuperfluous can only remove empty pages at the end; // find if there are pages without content following pPage // and if so request a call to CheckPageDescs() - SwPageFrame const* pNext(pPage); SwViewShell *pSh = pRoot->GetCurrShell(); - if (pSh && pSh->Imp()->IsAction()) + // tdf#152983 pPage is null when called from SwHeadFootFrame ctor + if (pPage && pSh && pSh->Imp()->IsAction()) { + SwPageFrame const* pNext(pPage); while ((pNext = static_cast<SwPageFrame const*>(pNext->GetNext()))) { if (!sw::IsPageFrameEmpty(*pNext) && !pNext->IsFootnotePage()) |