sw/source/writerfilter/dmapper/PropertyMap.cxx |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

New commits:
commit c726ccaa5727fe85b20fbd829506e25db369fc24
Author:     Andras Timar <[email protected]>
AuthorDate: Mon Feb 23 07:50:40 2026 +0100
Commit:     Andras Timar <[email protected]>
CommitDate: Mon Feb 23 15:38:48 2026 +0100

    writerfilter: add null check for GetPaM() in EmulateSectPrBelowSpacing
    
    Defensive null check to avoid a potential crash if the cursor's
    underlying PaM has been invalidated by the time
    EmulateSectPrBelowSpacing runs.
    
    Change-Id: I021ee06c7fb562a6b9ec911700fd5196191d81d4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200007
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Andras Timar <[email protected]>

diff --git a/sw/source/writerfilter/dmapper/PropertyMap.cxx 
b/sw/source/writerfilter/dmapper/PropertyMap.cxx
index f25ddea4fcfa..ff5de6b5d2ad 100644
--- a/sw/source/writerfilter/dmapper/PropertyMap.cxx
+++ b/sw/source/writerfilter/dmapper/PropertyMap.cxx
@@ -1581,7 +1581,9 @@ void 
SectionPropertyMap::EmulateSectPrBelowSpacing(DomainMapper_Impl& rDM_Impl)
     // Also, if m_xStartingRange starts with a table (which also doesn't have 
above spacing)
     // then again the below spacing can be ignored since no consolidation is 
needed.
     auto pCursor = dynamic_cast<SwXTextCursor*>(m_xStartingRange.get());
-    if (!pCursor || pCursor->GetPaM()->GetPointNode().FindTableNode())
+    if (!pCursor || !pCursor->GetPaM())
+        return;
+    if (pCursor->GetPaM()->GetPointNode().FindTableNode())
         return; // no emulation needed: section starts with a table (i.e. a 
zero top margin)
 
     SwPaM aPaM(pCursor->GetPaM()->GetPointNode()); // at start of section, 
contentIndex(0)
commit 080c4cbe83183a1e9ebaef54a4133d131adaa7de
Author:     Justin Luth <[email protected]>
AuthorDate: Mon Jan 5 14:12:08 2026 -0500
Commit:     Andras Timar <[email protected]>
CommitDate: Mon Feb 23 15:38:40 2026 +0100

    writerfilter: no m_xPreStartingRange if not gotoPreviousParagraph
    
    Based on a code read, it doesn't make any sense to pretend
    we have a useful value in m_xPreStartingRange
    if this could not move backwards.
    
    Better not to have a value at all
    than to confuse someone who now expects to find content
    before m_xStartingRange.
    
    Introduced in 25.8 with commit a2a88f0073bdd5119745679daa61469e87002579
        tdf#165717, tdf#165718 additional hack to apply continuous section 
breaks
        Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182830
    
    Change-Id: Ib092cfd755a09b733c7433417c2b7d7eaaef7aa9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196582
    Reviewed-by: Justin Luth <[email protected]>
    Tested-by: Jenkins
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200006
    Reviewed-by: Andras Timar <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/sw/source/writerfilter/dmapper/PropertyMap.cxx 
b/sw/source/writerfilter/dmapper/PropertyMap.cxx
index 6af004c1887e..f25ddea4fcfa 100644
--- a/sw/source/writerfilter/dmapper/PropertyMap.cxx
+++ b/sw/source/writerfilter/dmapper/PropertyMap.cxx
@@ -2193,8 +2193,8 @@ void SectionPropertyMap::SetStart( const uno::Reference< 
text::XTextRange >& xRa
             
m_xStartingRange->getText()->createTextCursorByRange(m_xStartingRange), 
uno::UNO_QUERY_THROW);
         // CAUTION: gotoPreviousParagraph skips over tables,
         // so this range does not necessarily indicate the end of the previous 
section
-        xPCursor->gotoPreviousParagraph(false);
-        m_xPreStartingRange = xPCursor;
+        if (xPCursor->gotoPreviousParagraph(false))
+            m_xPreStartingRange = xPCursor;
     }
     catch (const uno::Exception&)
     {

Reply via email to