diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2023-06-01 20:19:36 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2023-07-17 11:52:16 +0200 |
commit | 7e985c49d2d948691b29f819e9d9bebdd669922e (patch) | |
tree | a495464bab736b2dda0c1052e2e46bc3c7b3a480 | |
parent | 635fbb4d2958730c0f3ae2bd525bc7f06fea6f73 (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)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152510
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit d3b64de9581bd5e36ced007ff2e9139bd0343a35)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152533
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
(cherry picked from commit ce863cf085e093e7385818a7d6d598a161e33a28)
Change-Id: Iad84b7b422126e050493dc3b181d47c4dca2fae2
-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 5e2ae77f8f50..9f25b8506b29 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -829,6 +829,12 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf150606) } #endif +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf152983) +{ + //just care it doesn't crash/assert + createDoc("tdf152983-1-min.docx"); +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFootnote) { loadURL("private:factory/swriter", nullptr); diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx index e92fb0391f74..14aa081621f1 100644 --- a/sw/source/core/layout/wsfrm.cxx +++ b/sw/source/core/layout/wsfrm.cxx @@ -1204,10 +1204,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()) |