[Libreoffice-commits] core.git: sw/source
Caolán McNamara
caolanm at redhat.com
Wed Dec 20 09:55:55 UTC 2017
sw/source/filter/html/htmlgrin.cxx | 7 +++----
sw/source/filter/html/swhtml.cxx | 12 +++++++-----
sw/source/filter/html/swhtml.hxx | 2 ++
3 files changed, 12 insertions(+), 9 deletions(-)
New commits:
commit e192796dde1c1d94aa05a70b55e04c0f778f4389
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue Dec 19 21:14:22 2017 +0000
ofz: Null-deref
reuse the safety check used elsewhere
Change-Id: Ic7d613fea1d93e76a03183a02127499a5d8dd15d
Reviewed-on: https://gerrit.libreoffice.org/46825
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx
index 53ec083588ce..4f163ec49cf8 100644
--- a/sw/source/filter/html/htmlgrin.cxx
+++ b/sw/source/filter/html/htmlgrin.cxx
@@ -1335,13 +1335,12 @@ void SwHTMLParser::StripTrailingPara()
bool bSetSmallFont = false;
SwContentNode* pCNd = m_pPam->GetContentNode();
+ sal_uLong nNodeIdx = m_pPam->GetPoint()->nNode.GetIndex();
if( !m_pPam->GetPoint()->nContent.GetIndex() )
{
- if( pCNd && pCNd->StartOfSectionIndex()+2 <
- pCNd->EndOfSectionIndex() )
+ if( pCNd && pCNd->StartOfSectionIndex() + 2 <
+ pCNd->EndOfSectionIndex() && CanRemoveNode(nNodeIdx))
{
- sal_uLong nNodeIdx = m_pPam->GetPoint()->nNode.GetIndex();
-
const SwFrameFormats& rFrameFormatTable = *m_xDoc->GetSpzFrameFormats();
for( auto pFormat : rFrameFormatTable )
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index 3860c6407aaf..2e22f5345037 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -559,6 +559,12 @@ SvParserState SwHTMLParser::CallParser()
return eRet;
}
+bool SwHTMLParser::CanRemoveNode(sal_uLong nNodeIdx) const
+{
+ const SwNode *pPrev = m_xDoc->GetNodes()[nNodeIdx - 1];
+ return pPrev->IsContentNode() || (pPrev->IsEndNode() && pPrev->StartOfSectionNode()->IsSectionNode());
+}
+
void SwHTMLParser::Continue( HtmlTokenId nToken )
{
#ifdef DBG_UTIL
@@ -749,11 +755,7 @@ if( m_pSttNdIdx->GetIndex()+1 == m_pPam->GetBound( false ).nNode.GetIndex() )
if( IsNewDoc() )
{
- const SwNode *pPrev = m_xDoc->GetNodes()[nNodeIdx -1];
- if( !m_pPam->GetPoint()->nContent.GetIndex() &&
- ( pPrev->IsContentNode() ||
- (pPrev->IsEndNode() &&
- pPrev->StartOfSectionNode()->IsSectionNode()) ) )
+ if (!m_pPam->GetPoint()->nContent.GetIndex() && CanRemoveNode(nNodeIdx))
{
SwContentNode* pCNd = m_pPam->GetContentNode();
if( pCNd && pCNd->StartOfSectionIndex()+2 <
diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx
index 198cc2ab739b..a023d3549cfa 100644
--- a/sw/source/filter/html/swhtml.hxx
+++ b/sw/source/filter/html/swhtml.hxx
@@ -860,6 +860,8 @@ private:
// Remove empty paragraph at the PaM position
void StripTrailingPara();
+ // If removing an empty node would corrupt the document
+ bool CanRemoveNode(sal_uLong nNodeIdx) const;
// Are there fly frames in the current paragraph?
bool HasCurrentParaFlys( bool bNoSurroundOnly = false,
More information about the Libreoffice-commits
mailing list