From 56cda453daf71a368f316cb559e3e1f529e1c4fa Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 26 Sep 2016 14:31:54 +0200 Subject: CppunitTest_sw_rtfimport: fix ASan/UBSan build failure pDocShell->GetWrtShell() can be nullptr, even if pDocShell is not. Change-Id: I2d60475abe545c2dbb13ede74d2d65432a3c93a7 --- sw/source/core/txtnode/ndtxt.cxx | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 7e2470e1422b..f833f7e1849d 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -1162,21 +1162,24 @@ void SwTextNode::Update( // The cursors of other shells shouldn't be moved, either. if (SwDocShell* pDocShell = GetDoc()->GetDocShell()) { - for (SwViewShell& rShell : pDocShell->GetWrtShell()->GetRingContainer()) + if (pDocShell->GetWrtShell()) { - auto pWrtShell = dynamic_cast(&rShell); - if (!pWrtShell || pWrtShell == pDocShell->GetWrtShell()) - continue; + for (SwViewShell& rShell : pDocShell->GetWrtShell()->GetRingContainer()) + { + auto pWrtShell = dynamic_cast(&rShell); + if (!pWrtShell || pWrtShell == pDocShell->GetWrtShell()) + continue; - SwShellCursor* pCursor = pWrtShell->GetCursor_(); - if (!pCursor) - continue; + SwShellCursor* pCursor = pWrtShell->GetCursor_(); + if (!pCursor) + continue; - SwIndex& rIndex = const_cast(pCursor->Start()->nContent); - if (&pCursor->Start()->nNode.GetNode() == this && rIndex.GetIndex() == rPos.GetIndex()) - { - // The cursor position of this other shell is exactly our insert position. - rIndex.Assign(&aTmpIdxReg, rIndex.GetIndex()); + SwIndex& rIndex = const_cast(pCursor->Start()->nContent); + if (&pCursor->Start()->nNode.GetNode() == this && rIndex.GetIndex() == rPos.GetIndex()) + { + // The cursor position of this other shell is exactly our insert position. + rIndex.Assign(&aTmpIdxReg, rIndex.GetIndex()); + } } } } -- cgit v1.2.3