summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2023-05-19 10:49:28 +0200
committerAndras Timar <andras.timar@collabora.com>2023-05-28 20:56:05 +0200
commite241a92318e53f8f472d9ed63e2cd90c5b18c806 (patch)
tree95a38706b0ada6011217c69a6b4e521055af4c6c
parent5b4a36483719e3dbc87bde8df3f78f2c840be649 (diff)
sw: fix crash in GotoNextLayoutTextFrame/GotoPrevLayoutTextFrame
See https://crashreport.libreoffice.org/stats/signature/sw::GotoPrevLayoutTextFrame(SwNodeIndex%20&,SwRootFrame%20const%20*) and https://crashreport.libreoffice.org/stats/signature/sw::GotoNextLayoutTextFrame(SwNodeIndex%20&,SwRootFrame%20const%20*) Change-Id: I2233078051bd653de5634f1e0dabab9c1f59acb0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151994 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> Tested-by: Jenkins (cherry picked from commit 4269977853bd51c4fc7f93e497246da163d71f17) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152030 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--sw/source/core/doc/docnum.cxx21
1 files changed, 16 insertions, 5 deletions
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index b4d32ea25b61..703c15f2187d 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -1439,11 +1439,16 @@ GotoPrevLayoutTextFrame(SwNodeIndex & rIndex, SwRootFrame const*const pLayout)
{
if (rIndex.GetNode().IsTextNode())
{
- if (rIndex.GetNode().GetRedlineMergeFlag() != SwNode::Merge::None &&
- // not a tracked row deletion in Hide Changes mode
- rIndex.GetNode().GetTextNode()->getLayoutFrame(pLayout) )
+ if (rIndex.GetNode().GetRedlineMergeFlag() != SwNode::Merge::None)
{
- rIndex = *static_cast<SwTextFrame*>(rIndex.GetNode().GetTextNode()->getLayoutFrame(pLayout))->GetMergedPara()->pFirstNode;
+ // not a tracked row deletion in Hide Changes mode
+ if (SwContentFrame* pFrame = rIndex.GetNode().GetTextNode()->getLayoutFrame(pLayout))
+ {
+ if (sw::MergedPara* pMerged = static_cast<SwTextFrame*>(pFrame)->GetMergedPara())
+ {
+ rIndex = pMerged->pFirstNode->GetIndex();
+ }
+ }
}
}
else if (rIndex.GetNode().IsEndNode())
@@ -1471,7 +1476,13 @@ GotoNextLayoutTextFrame(SwNodeIndex & rIndex, SwRootFrame const*const pLayout)
{
if (rIndex.GetNode().GetRedlineMergeFlag() != SwNode::Merge::None)
{
- rIndex = *static_cast<SwTextFrame*>(rIndex.GetNode().GetTextNode()->getLayoutFrame(pLayout))->GetMergedPara()->pLastNode;
+ if (SwContentFrame* pFrame = rIndex.GetNode().GetTextNode()->getLayoutFrame(pLayout))
+ {
+ if (sw::MergedPara* pMerged = static_cast<SwTextFrame*>(pFrame)->GetMergedPara())
+ {
+ rIndex = pMerged->pLastNode->GetIndex();
+ }
+ }
}
}
else if (rIndex.GetNode().IsTableNode())