[Libreoffice-commits] core.git: sw/source

Miklos Vajna vmiklos at collabora.co.uk
Mon Sep 26 12:34:34 UTC 2016


 sw/source/core/txtnode/ndtxt.cxx |   27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

New commits:
commit 56cda453daf71a368f316cb559e3e1f529e1c4fa
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Sep 26 14:31:54 2016 +0200

    CppunitTest_sw_rtfimport: fix ASan/UBSan build failure
    
    pDocShell->GetWrtShell() can be nullptr, even if pDocShell is not.
    
    Change-Id: I2d60475abe545c2dbb13ede74d2d65432a3c93a7

diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 7e2470e..f833f7e 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<SwWrtShell*>(&rShell);
-                if (!pWrtShell || pWrtShell == pDocShell->GetWrtShell())
-                    continue;
+                for (SwViewShell& rShell : pDocShell->GetWrtShell()->GetRingContainer())
+                {
+                    auto pWrtShell = dynamic_cast<SwWrtShell*>(&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<SwIndex&>(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<SwIndex&>(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());
+                    }
                 }
             }
         }


More information about the Libreoffice-commits mailing list