sw/source/core/crsr/crbm.cxx |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

New commits:
commit 4d3b750d08d05c475fb38f8b3961696d9cc9882f
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Fri May 20 15:46:20 2022 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Mon May 23 10:52:57 2022 +0200

    sw_redlinehide: fix crash in IsMarkHidden() if pointing to table node
    
    This is called during mail merge from documentStartPageNumber()
    and if the document starts with a table, the passed UNO mark will point
    to SwTableNode.
    
    (regression from commit 943d9be770e550d20ca72274fa5e914d1f61e605)
    
    Change-Id: Ic69c12ba0d819eda85de5dde95e35a8071466c2e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134692
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/source/core/crsr/crbm.cxx b/sw/source/core/crsr/crbm.cxx
index 9e2027a2ceba..02f554014568 100644
--- a/sw/source/core/crsr/crbm.cxx
+++ b/sw/source/core/crsr/crbm.cxx
@@ -128,9 +128,14 @@ bool IsMarkHidden(SwRootFrame const& rLayout, 
::sw::mark::IMark const& rMark)
     {
         return false;
     }
-    SwTextNode const& rNode(*rMark.GetMarkPos().nNode.GetNode().GetTextNode());
+    SwNode const& rNode(rMark.GetMarkPos().nNode.GetNode());
+    SwTextNode const*const pTextNode(rNode.GetTextNode());
+    if (pTextNode == nullptr)
+    {   // UNO_BOOKMARK may point to table node
+        return rNode.GetRedlineMergeFlag() == SwNode::Merge::Hidden;
+    }
     SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(
-        rNode.getLayoutFrame(&rLayout)));
+        pTextNode->getLayoutFrame(&rLayout)));
     if (!pFrame)
     {
         return true;
@@ -145,14 +150,14 @@ bool IsMarkHidden(SwRootFrame const& rLayout, 
::sw::mark::IMark const& rMark)
     }
     else
     {
-        if (rMark.GetMarkPos().nContent.GetIndex() == rNode.Len())
+        if (rMark.GetMarkPos().nContent.GetIndex() == pTextNode->Len())
         {   // at end of node: never deleted (except if node deleted)
-            return rNode.GetRedlineMergeFlag() == SwNode::Merge::Hidden;
+            return pTextNode->GetRedlineMergeFlag() == SwNode::Merge::Hidden;
         }
         else
         {   // check character following mark pos
             return pFrame->MapModelToViewPos(rMark.GetMarkPos())
-                == pFrame->MapModelToView(&rNode, 
rMark.GetMarkPos().nContent.GetIndex() + 1);
+                == pFrame->MapModelToView(pTextNode, 
rMark.GetMarkPos().nContent.GetIndex() + 1);
         }
     }
 }

Reply via email to