Kaydet (Commit) 1b3fc6e2 authored tarafından Caolán McNamara's avatar Caolán McNamara

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/42375Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 2729a1c9
......@@ -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);
}
}
......
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