summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-05-01 15:17:48 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-05-01 21:24:01 +0200
commit3def66880874e5d0f06a48abfb6d3a95b6b0dae4 (patch)
tree6230a15f5af7cc25e9d3666f9d4618047803cbd2
parentcfe137da10080b3d626ee9791e3b0b1dd0e7bb6e (diff)
ofz#7002 Direct-leak
Change-Id: I7a4a00663498fe600e8dace95c60210a9f006a6f Reviewed-on: https://gerrit.libreoffice.org/53696 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/source/filter/xml/xmltbli.cxx10
-rw-r--r--sw/source/filter/xml/xmltbli.hxx1
2 files changed, 9 insertions, 2 deletions
diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx
index 989fe07af328..98ddb181baf1 100644
--- a/sw/source/filter/xml/xmltbli.cxx
+++ b/sw/source/filter/xml/xmltbli.cxx
@@ -1251,6 +1251,7 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport,
m_pRows( new SwXMLTableRows_Impl ),
m_pTableNode( nullptr ),
m_pBox1( nullptr ),
+ m_bOwnsBox1( false ),
m_pSttNd1( nullptr ),
m_pBoxFormat( nullptr ),
m_pLineFormat( nullptr ),
@@ -1391,6 +1392,7 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport,
m_pRows( new SwXMLTableRows_Impl ),
m_pTableNode( pTable->m_pTableNode ),
m_pBox1( nullptr ),
+ m_bOwnsBox1( false ),
m_pSttNd1( nullptr ),
m_pBoxFormat( nullptr ),
m_pLineFormat( nullptr ),
@@ -1408,6 +1410,8 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport,
SwXMLTableContext::~SwXMLTableContext()
{
+ if (m_bOwnsBox1)
+ delete m_pBox1;
delete m_pColumnDefaultCellStyleNames;
delete m_pSharedBoxFormats;
delete m_pRows;
@@ -1808,6 +1812,7 @@ SwTableBox *SwXMLTableContext::NewTableBox( const SwStartNode *pStNd,
pBox = m_pBox1;
pBox->SetUpper( pUpper );
m_pBox1 = nullptr;
+ m_bOwnsBox1 = false;
}
else
pBox = new SwTableBox( m_pBoxFormat, *pStNd, pUpper );
@@ -2614,6 +2619,7 @@ void SwXMLTableContext::MakeTable()
m_pTableNode->GetDoc()->getIDocumentContentOperations().DeleteSection( m_pTableNode );
m_pTableNode = nullptr;
m_pBox1 = nullptr;
+ m_bOwnsBox1 = false;
m_pSttNd1 = nullptr;
return;
}
@@ -2732,10 +2738,10 @@ void SwXMLTableContext::MakeTable()
}
SwTableLine *pLine1 = m_pTableNode->GetTable().GetTabLines()[0U];
- OSL_ENSURE( m_pBox1 == pLine1->GetTabBoxes()[0U],
- "Why is box 1 change?" );
+ assert(m_pBox1 == pLine1->GetTabBoxes()[0] && !m_bOwnsBox1 && "Why is box 1 change?");
m_pBox1->m_pStartNode = m_pSttNd1;
pLine1->GetTabBoxes().erase( pLine1->GetTabBoxes().begin() );
+ m_bOwnsBox1 = true;
m_pLineFormat = static_cast<SwTableLineFormat*>(pLine1->GetFrameFormat());
m_pBoxFormat = static_cast<SwTableBoxFormat*>(m_pBox1->GetFrameFormat());
diff --git a/sw/source/filter/xml/xmltbli.hxx b/sw/source/filter/xml/xmltbli.hxx
index cc67ac13fa92..0fac390c2794 100644
--- a/sw/source/filter/xml/xmltbli.hxx
+++ b/sw/source/filter/xml/xmltbli.hxx
@@ -67,6 +67,7 @@ class SwXMLTableContext : public XMLTextTableContext
SwTableNode *m_pTableNode;
SwTableBox *m_pBox1;
+ bool m_bOwnsBox1;
const SwStartNode *m_pSttNd1;
SwTableBoxFormat *m_pBoxFormat;