From 66bdcb96ed9320398e57b06aabc30bd225de0cfa Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 13 Sep 2016 16:46:52 +0200 Subject: xmloff: invoke SvXMLImportContext destructor with proper namespace map The recent pRewindMap fix revealed that the xContext object is destroyed too late so the destructors containing half the import code (because where else would you put complex logic that can fail?) are invoked with the namespace map of the parent element, which breaks RDFa import and JunitTest_sfx2_complex. (regression from 32ccb4ea863651c22bf33cc15012971d2a2d2810) Change-Id: I0c897ea0cae2db4d35f2ba19ba2f6e8026f1b3ec --- xmloff/source/core/xmlimp.cxx | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'xmloff') diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index 5ef0b36ef303..52df8ce53ba8 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -775,9 +775,15 @@ rName ) throw(xml::sax::SAXException, uno::RuntimeException, std::exception) { - sal_uInt16 nCount = maContexts.size(); - SAL_WARN_IF( nCount == 0, "xmloff.core", "SvXMLImport::endElement: no context left" ); - if( nCount > 0 ) + auto const nCount = maContexts.size(); + if (nCount == 0) + { + SAL_WARN("xmloff.core", "SvXMLImport::endElement: no context left"); + return; + } + + SvXMLNamespaceMap * pRewindMap(nullptr); + { // Get topmost context and remove it from the stack. SvXMLImportContextRef xContext = maContexts.back(); @@ -794,16 +800,16 @@ rName // Call a EndElement at the current context. xContext->EndElement(); - // Get a namespace map to rewind. - SvXMLNamespaceMap *pRewindMap = xContext->TakeRewindMap(); + pRewindMap = xContext->TakeRewindMap(); + // note: delete xContext *before* rewinding namespace map! + } - // Rewind a namespace map. - if( pRewindMap ) - { - delete mpNamespaceMap; - mpNamespaceMap = pRewindMap; - } + // Rewind a namespace map. + if (pRewindMap) + { + delete mpNamespaceMap; + mpNamespaceMap = pRewindMap; } } -- cgit