sw/qa/extras/layout/data/tdf152983-1-min.docx |binary
 sw/qa/extras/layout/layout.cxx                |    6 ++++++
 sw/source/core/layout/wsfrm.cxx               |    5 +++--
 3 files changed, 9 insertions(+), 2 deletions(-)

New commits:
commit 5fd62052499be565c2649e6cf3dccaad25a66575
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Jun 1 20:19:36 2023 +0200
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Sun Jun 25 21:29:38 2023 +0200

    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.st...@allotropia.de>
    (cherry picked from commit d3b64de9581bd5e36ced007ff2e9139bd0343a35)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152533
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sw/qa/extras/layout/data/tdf152983-1-min.docx 
b/sw/qa/extras/layout/data/tdf152983-1-min.docx
new file mode 100644
index 000000000000..804e8fefe68f
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf152983-1-min.docx 
differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index eb6b36254276..c88d698ebc95 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -1267,6 +1267,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 f753a993aceb..c59717f94901 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -1227,10 +1227,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())

Reply via email to