summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2016-09-13 16:46:52 +0200
committerMichael Stahl <mstahl@redhat.com>2016-09-13 17:01:12 +0200
commit66bdcb96ed9320398e57b06aabc30bd225de0cfa (patch)
treee63711995a267cd232be6be7aaf564704555bc78 /xmloff
parent586789fe757c0eb350c360a49cf90431a0bd5b24 (diff)
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
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/core/xmlimp.cxx28
1 files changed, 17 insertions, 11 deletions
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;
}
}