[Libreoffice-commits] core.git: xmloff/source

Michael Stahl mstahl at redhat.com
Tue Sep 13 15:04:30 UTC 2016


 xmloff/source/core/xmlimp.cxx |   28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

New commits:
commit 66bdcb96ed9320398e57b06aabc30bd225de0cfa
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Sep 13 16:46:52 2016 +0200

    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

diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index 5ef0b36..52df8ce 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;
     }
 }
 


More information about the Libreoffice-commits mailing list