summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-06-23 12:27:34 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-06-24 10:10:54 +0200
commit66365b89f6f335e62db690add57482e91418c7d2 (patch)
treeb7c60f71977f183f51233fbe4e53aaaa5cf146d9
parent01fac859a5a2a5e65baca8052456ab7ae5bd95d7 (diff)
sw: fix crash in SwLayoutFrame::GetContentPos
FindPageFrame might return nullptr See https://crashreport.libreoffice.org/stats/signature/SwLayoutFrame::GetContentPos(Point%20&,bool,bool,SwCursorMoveState%20*,bool) Change-Id: Ic69d26de4ab234ebd6283ace640d689f0ebe8eb3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136307 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--sw/source/core/layout/trvlfrm.cxx24
1 files changed, 19 insertions, 5 deletions
diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index 6942dab6a2ba..375b9fe34fd6 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -1290,13 +1290,22 @@ const SwContentFrame *SwLayoutFrame::GetContentPos( Point& rPoint,
if( !pStart->GetPrev()->IsLayoutFrame() )
return nullptr;
pStart = static_cast<const SwLayoutFrame*>(pStart->GetPrev());
- pContent = pStart->IsInDocBody()
- ? pStart->ContainsContent()
- : pStart->FindPageFrame()->FindFirstBodyContent();
+ if( pStart->IsInDocBody() )
+ pContent = pStart->ContainsContent();
+ else
+ {
+ const SwPageFrame *pPage = pStart->FindPageFrame();
+ if( !pPage )
+ return nullptr;
+ pContent = pPage->FindFirstBodyContent();
+ }
}
if ( !pContent ) // Somewhere down the road we have to start with one!
{
- pContent = pStart->FindPageFrame()->GetUpper()->ContainsContent();
+ const SwPageFrame *pPage = pStart->FindPageFrame();
+ if( !pPage )
+ return nullptr;
+ pContent = pPage->GetUpper()->ContainsContent();
while ( pContent && !pContent->IsInDocBody() )
pContent = pContent->GetNextContentFrame();
if ( !pContent )
@@ -1314,7 +1323,12 @@ const SwContentFrame *SwLayoutFrame::GetContentPos( Point& rPoint,
pContent = pStart->ContainsContent();
}
else // Somewhere down the road we have to start with one!
- pContent = pStart->FindPageFrame()->GetUpper()->ContainsContent();
+ {
+ const SwPageFrame *pPage = pStart->FindPageFrame();
+ if( !pPage )
+ return nullptr;
+ pContent = pPage->GetUpper()->ContainsContent();
+ }
}
pActual = pContent;
}