diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-09-17 12:31:08 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-09-17 18:21:07 +0200 |
commit | 1b3fc6e2b8f3f36868657d623de21ce3e249efa0 (patch) | |
tree | f62f34b474ad56213cf98dc7f467076413166b9f /xmlscript | |
parent | 2729a1c9d34c2c32c73431b8a6bdf44df382658a (diff) |
ofz: fix leak on exception
#0 0x600ca0 in operator new(unsigned long) /src/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:82
#1 0x4802b4b in xmlscript::DocumentHandlerImpl::pushPrefix(rtl::OUString const&, rtl::OUString const&) /src/libreoffice/xmlscript/source/xml_helper/xml_impctx.cxx:259:32
#2 0x47ff026 in xmlscript::DocumentHandlerImpl::startElement(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> const&) /src/libreoffice/xmlscript/source/xml_helper/xml_impctx.cxx:480:17
#3 0x7665a34 in xmlscript::XMLBasicImporterBase::startElement(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> const&) /src/libreoffice/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx:537:25
#4 0x4c2831f in XMLBasicImportContext::StartElement(com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> const&) /src/libreoffice/xmloff/source/script/xmlbasici.cxx:84:21
#5 0x489c29b in SvXMLImport::startElement(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> const&) /src/libreoffice/xmloff/source/core/xmlimp.cxx:728:15
#6 0x4892ab7 in SvXMLImportContext::startUnknownElement(rtl::OUString const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::xml::sax::XFastAttributeList> const&) /src/libreoffice/xmloff/source/core/xmlictxt.cxx:124:14
#7 0x489ec2d in SvXMLImport::startUnknownElement(rtl::OUString const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::xml::sax::XFastAttributeList> const&) /src/libreoffice/xmloff/source/core/xmlimp.cxx:889:15
#8 0x86871f3 in (anonymous namespace)::Entity::startElement((anonymous namespace)::Event*) /src/libreoffice/sax/source/fastparser/fastparser.cxx:445:27
#9 0x86823f1 in sax_fastparser::FastSaxParserImpl::consume((anonymous namespace)::EventList&) /src/libreoffice/sax/source/fastparser/fastparser.cxx:960:25
#10 0x86812f8 in sax_fastparser::FastSaxParserImpl::parseStream(com::sun::star::xml::sax::InputSource const&) /src/libreoffice/sax/source/fastparser/fastparser.cxx:784:26
#11 0x489842e in SvXMLImport::parseStream(com::sun::star::xml::sax::InputSource const&) /src/libreoffice/xmloff/source/core/xmlimp.cxx:464:15
#12 0x837fb5d in filter::odfflatxml::OdfFlatXml::importer(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::xml::sax::XDocumentHandler> const&, com::sun::star::uno::Sequence<rtl::OUString> const&) /src/libreoffice/filter/source/odfflatxml/OdfFlatXml.cxx:149:26
Change-Id: Ic4ba40dca088a333a1271e005a05bd3c6e7d70ac
Reviewed-on: https://gerrit.libreoffice.org/42375
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'xmlscript')
-rw-r--r-- | xmlscript/source/xml_helper/xml_impctx.cxx | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/xmlscript/source/xml_helper/xml_impctx.cxx b/xmlscript/source/xml_helper/xml_impctx.cxx index 0d70c782bfaa..79d7889698b7 100644 --- a/xmlscript/source/xml_helper/xml_impctx.cxx +++ b/xmlscript/source/xml_helper/xml_impctx.cxx @@ -68,7 +68,7 @@ struct PrefixEntry }; typedef std::unordered_map< - OUString, PrefixEntry *, OUStringHash > t_OUString2PrefixMap; + OUString, std::unique_ptr<PrefixEntry>, OUStringHash > t_OUString2PrefixMap; struct ElementEntry { @@ -258,13 +258,13 @@ inline void DocumentHandlerImpl::pushPrefix( { PrefixEntry * pEntry = new PrefixEntry(); pEntry->m_Uids.push_back( nUid ); // latest id for prefix - m_prefixes[ rPrefix ] = pEntry; + m_prefixes[rPrefix].reset(pEntry); } else { - PrefixEntry * pEntry = iFind->second; - SAL_WARN_IF( pEntry->m_Uids.empty(), "xmlscript.xmlhelper", "pEntry->m_Uids is empty" ); - pEntry->m_Uids.push_back( nUid ); + PrefixEntry& rEntry = *iFind->second; + SAL_WARN_IF(rEntry.m_Uids.empty(), "xmlscript.xmlhelper", "pEntry->m_Uids is empty"); + rEntry.m_Uids.push_back(nUid); } m_aLastPrefix_lookup = rPrefix; @@ -277,12 +277,11 @@ inline void DocumentHandlerImpl::popPrefix( t_OUString2PrefixMap::iterator iFind( m_prefixes.find( rPrefix ) ); if (iFind != m_prefixes.end()) // unused prefix { - PrefixEntry * pEntry = iFind->second; - pEntry->m_Uids.pop_back(); // pop last id for prefix - if (pEntry->m_Uids.empty()) // erase prefix key + PrefixEntry& rEntry = *iFind->second; + rEntry.m_Uids.pop_back(); // pop last id for prefix + if (rEntry.m_Uids.empty()) // erase prefix key { - m_prefixes.erase( iFind ); - delete pEntry; + m_prefixes.erase(iFind); } } |