diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-12-17 16:50:47 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-12-17 16:51:17 +0100 |
commit | d1385731031fc30cfc2c182279ba5d4feb497328 (patch) | |
tree | 65e54aa6712e8bf78a5a49fca0f65d80fa3d6383 /xmloff | |
parent | c535f115efddc5195d162517ad67ed013229de57 (diff) |
Avoid memory leaks
...when exceptions get thrown while a context owns an rewind map
Change-Id: I90d26caa57ef2ff508e6eae05ddbc62cdb3f01ea
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/core/xmlictxt.cxx | 1 | ||||
-rw-r--r-- | xmloff/source/core/xmlimp.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/transform/TransformerBase.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/transform/TransformerContext.cxx | 1 | ||||
-rw-r--r-- | xmloff/source/transform/TransformerContext.hxx | 5 |
5 files changed, 9 insertions, 6 deletions
diff --git a/xmloff/source/core/xmlictxt.cxx b/xmloff/source/core/xmlictxt.cxx index aa1aa2ec6a7a..ff7e4399c911 100644 --- a/xmloff/source/core/xmlictxt.cxx +++ b/xmloff/source/core/xmlictxt.cxx @@ -47,6 +47,7 @@ SvXMLImportContext::SvXMLImportContext( SvXMLImport& rImp ) : SvXMLImportContext::~SvXMLImportContext() { + delete mpRewindMap; } SvXMLImportContext *SvXMLImportContext::CreateChildContext( sal_uInt16 nPrefix, diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index 92fd16a82482..8ade9dc9a626 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -731,7 +731,7 @@ void SAL_CALL SvXMLImport::startElement( const OUString& rName, // Remember old namespace map. if( pRewindMap ) - pContext->SetRewindMap( pRewindMap ); + pContext->PutRewindMap( pRewindMap ); // Call a startElement at the new context. pContext->StartElement( xAttrList ); @@ -768,7 +768,7 @@ rName pContext->EndElement(); // Get a namespace map to rewind. - SvXMLNamespaceMap *pRewindMap = pContext->GetRewindMap(); + SvXMLNamespaceMap *pRewindMap = pContext->TakeRewindMap(); // Delete the current context. pContext->ReleaseRef(); diff --git a/xmloff/source/transform/TransformerBase.cxx b/xmloff/source/transform/TransformerBase.cxx index 71a78dde00dc..57120b00171c 100644 --- a/xmloff/source/transform/TransformerBase.cxx +++ b/xmloff/source/transform/TransformerBase.cxx @@ -303,7 +303,7 @@ void SAL_CALL XMLTransformerBase::startElement( const OUString& rName, // Remember old namespace map. if( pRewindMap ) - xContext->SetRewindMap( pRewindMap ); + xContext->PutRewindMap( pRewindMap ); // Push context on stack. m_pContexts.push_back( xContext ); @@ -336,7 +336,7 @@ rName m_pContexts.pop_back(); // Get a namespace map to rewind. - SvXMLNamespaceMap *pRewindMap = xContext->GetRewindMap(); + SvXMLNamespaceMap *pRewindMap = xContext->TakeRewindMap(); // Delete the current context. xContext = nullptr; diff --git a/xmloff/source/transform/TransformerContext.cxx b/xmloff/source/transform/TransformerContext.cxx index d245314774f6..72adbe6b519f 100644 --- a/xmloff/source/transform/TransformerContext.cxx +++ b/xmloff/source/transform/TransformerContext.cxx @@ -56,6 +56,7 @@ XMLTransformerContext::XMLTransformerContext( XMLTransformerBase& rImp, XMLTransformerContext::~XMLTransformerContext() { + delete m_pRewindMap; } rtl::Reference<XMLTransformerContext> XMLTransformerContext::CreateChildContext( sal_uInt16 nPrefix, diff --git a/xmloff/source/transform/TransformerContext.hxx b/xmloff/source/transform/TransformerContext.hxx index a42e982a4dec..e51443336b81 100644 --- a/xmloff/source/transform/TransformerContext.hxx +++ b/xmloff/source/transform/TransformerContext.hxx @@ -39,8 +39,9 @@ class XMLTransformerContext : public ::salhelper::SimpleReferenceObject SvXMLNamespaceMap *m_pRewindMap; - SvXMLNamespaceMap *GetRewindMap() const { return m_pRewindMap; } - void SetRewindMap( SvXMLNamespaceMap *p ) { m_pRewindMap = p; } + SvXMLNamespaceMap *TakeRewindMap() + { auto p = m_pRewindMap; m_pRewindMap = nullptr; return p; } + void PutRewindMap( SvXMLNamespaceMap *p ) { m_pRewindMap = p; } protected: |