[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - sw/source

Michael Stahl Michael.Stahl at cib.de
Thu Jun 14 14:14:49 UTC 2018


 sw/source/core/docnode/node.cxx  |   12 +++++-------
 sw/source/core/txtnode/ndtxt.cxx |    6 ++----
 2 files changed, 7 insertions(+), 11 deletions(-)

New commits:
commit 3ddae0546ac127d5c00448f8521f3a9393500864
Author: Michael Stahl <Michael.Stahl at cib.de>
Date:   Wed Jun 13 11:30:46 2018 +0200

    sw_redlinehide: try to fix UBSAN issue in ~SwContentNode
    
    /sw/source/core/text/txtfrm.cxx:987:16: runtime error: downcast of address 0x2b53270e5890 which does not point to an object of type 'const SwTextNode'
    0x2b53270e5890: note: object is of type 'SwContentNode'
     00 00 00 00  70 f9 c7 cb 52 2b 00 00  60 5c 7a 00 e0 60 00 00  f0 5b 0e 27 53 2b 00 00  40 15 18 00
                  ^~~~~~~~~~~~~~~~~~~~~~~
                  vptr for 'SwContentNode'
    0 in SwTextFrame::GetTextNodeFirst() const /sw/source/core/text/txtfrm.cxx:987:16
    1 in SwFrame::InvalidatePage(SwPageFrame const*) const /sw/source/core/layout/wsfrm.cxx:702:21
    2 in SwContentFrame::Cut() /sw/source/core/layout/wsfrm.cxx:1111:5
    3 in SwContentNode::DelFrames(bool) /sw/source/core/docnode/node.cxx:1361:9
    4 in SwContentNode::~SwContentNode() /sw/source/core/docnode/node.cxx:1017:5
    5 in SwTextNode::~SwTextNode() /sw/source/core/txtnode/ndtxt.cxx:270:1
    
    So call this from the ~SwTextNode instead, while it's still a
    SwTextNode.
    
    Also revert the order of resetting the wrong-flags
    to what it was before b75e052d31ec8854cad3bda7d372dcfcd50c9609,
    as DelFrames_TextNodePart() before DelFrames() will cause the
    root's SetNeedGrammarCheck to be called, which nobody will notice in
    practice, but...
    
    Change-Id: I0f4f38a484a28dd13a0696bb083300f9ec1e0836
    Reviewed-on: https://gerrit.libreoffice.org/55739
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit 90802a1ee007be10239cb09db7a41580311cf075)

diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index 337483f81de1..da7857d6def0 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -1012,7 +1012,10 @@ SwContentNode::~SwContentNode()
 {
     // The base class SwClient of SwFrame excludes itself from the dependency list!
     // Thus, we need to delete all Frames in the dependency list.
-    DelFrames(false);
+    if (!IsTextNode()) // see ~SwTextNode
+    {
+        DelFrames(false);
+    }
 
     m_aCondCollListener.EndListeningAll();
     m_pCondColl = nullptr;
@@ -1305,7 +1308,7 @@ void SwContentNode::MakeFrames( SwContentNode& rNode )
  *
  * An input param to identify if the acc table should be disposed.
  */
-void SwContentNode::DelFrames( bool bIsDisposeAccTable )
+void SwContentNode::DelFrames(bool /*removeme*/)
 {
     if( !HasWriterListeners() )
         return;
@@ -1359,11 +1362,6 @@ void SwContentNode::DelFrames( bool bIsDisposeAccTable )
         pFrame->Cut();
         SwFrame::DestroyFrame(pFrame);
     }
-
-    if( bIsDisposeAccTable && IsTextNode() )
-    {
-        GetTextNode()->DelFrames_TextNodePart();
-    }
 }
 
 SwContentNode *SwContentNode::JoinNext()
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 98ababf17492..448ba6cd44ce 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -263,10 +263,8 @@ SwTextNode::~SwTextNode()
 
     InitSwParaStatistics( false );
 
-    if (HasWriterListeners())
-    {
-        DelFrames_TextNodePart();
-    }
+    DelFrames(false); // must be called here while it's still a SwTextNode
+    DelFrames_TextNodePart();
 }
 
 void SwTextNode::FileLoadedInitHints()


More information about the Libreoffice-commits mailing list