Kaydet (Commit) 90802a1e authored tarafından Michael Stahl's avatar Michael Stahl

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 b75e052d,
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/55739Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst 3087011e
...@@ -1014,7 +1014,10 @@ SwContentNode::~SwContentNode() ...@@ -1014,7 +1014,10 @@ SwContentNode::~SwContentNode()
{ {
// The base class SwClient of SwFrame excludes itself from the dependency list! // The base class SwClient of SwFrame excludes itself from the dependency list!
// Thus, we need to delete all Frames in 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_aCondCollListener.EndListeningAll();
m_pCondColl = nullptr; m_pCondColl = nullptr;
...@@ -1307,7 +1310,7 @@ void SwContentNode::MakeFrames( SwContentNode& rNode ) ...@@ -1307,7 +1310,7 @@ void SwContentNode::MakeFrames( SwContentNode& rNode )
* *
* An input param to identify if the acc table should be disposed. * An input param to identify if the acc table should be disposed.
*/ */
void SwContentNode::DelFrames( bool bIsDisposeAccTable ) void SwContentNode::DelFrames(bool /*removeme*/)
{ {
if( !HasWriterListeners() ) if( !HasWriterListeners() )
return; return;
...@@ -1361,11 +1364,6 @@ void SwContentNode::DelFrames( bool bIsDisposeAccTable ) ...@@ -1361,11 +1364,6 @@ void SwContentNode::DelFrames( bool bIsDisposeAccTable )
pFrame->Cut(); pFrame->Cut();
SwFrame::DestroyFrame(pFrame); SwFrame::DestroyFrame(pFrame);
} }
if( bIsDisposeAccTable && IsTextNode() )
{
GetTextNode()->DelFrames_TextNodePart();
}
} }
SwContentNode *SwContentNode::JoinNext() SwContentNode *SwContentNode::JoinNext()
......
...@@ -263,10 +263,8 @@ SwTextNode::~SwTextNode() ...@@ -263,10 +263,8 @@ SwTextNode::~SwTextNode()
InitSwParaStatistics( false ); InitSwParaStatistics( false );
if (HasWriterListeners()) DelFrames(false); // must be called here while it's still a SwTextNode
{ DelFrames_TextNodePart();
DelFrames_TextNodePart();
}
} }
void SwTextNode::FileLoadedInitHints() void SwTextNode::FileLoadedInitHints()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment