[Libreoffice-commits] core.git: oox/source sax/source

Kohei Yoshida kohei.yoshida at collabora.com
Mon Jun 30 17:07:28 PDT 2014


 oox/source/core/xmlfilterbase.cxx    |    6 +++++-
 sax/source/fastparser/fastparser.cxx |    3 +++
 2 files changed, 8 insertions(+), 1 deletion(-)

New commits:
commit dc93074f71f91efd8a615ad8f1a5289deb210b75
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Jun 30 20:03:28 2014 -0400

    Use a new fast parser instance for each XML fragment.
    
    Otherwise a crash ensues when the threaded XML parsing kicks in.
    
    Change-Id: Ic41e5a29bbb860d7b63b70f2f0d8896264d9d53e

diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index 486946c..af0567b 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -171,6 +171,7 @@ struct XmlFilterBaseImpl
 {
     typedef RefMap< OUString, Relations > RelationsMap;
 
+    Reference<XComponentContext>   mxContext;
     FastParser                     maFastParser;
     const OUString                 maBinSuffix;
     const OUString                 maVmlSuffix;
@@ -182,6 +183,7 @@ struct XmlFilterBaseImpl
 };
 
 XmlFilterBaseImpl::XmlFilterBaseImpl( const Reference< XComponentContext >& rxContext ) throw( RuntimeException ) :
+    mxContext(rxContext),
     maFastParser( rxContext ),
     maBinSuffix( ".bin" ),
     maVmlSuffix( ".vml" )
@@ -272,7 +274,9 @@ OUString XmlFilterBase::getFragmentPathFromFirstTypeFromOfficeDoc( const OUStrin
 
 bool XmlFilterBase::importFragment( const rtl::Reference<FragmentHandler>& rxHandler )
 {
-    return importFragment(rxHandler, mxImpl->maFastParser);
+    FastParser aParser(mxImpl->mxContext);
+    registerNamespaces(aParser);
+    return importFragment(rxHandler, aParser);
 }
 
 bool XmlFilterBase::importFragment( const rtl::Reference<FragmentHandler>& rxHandler, FastParser& rParser )
diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx
index 82378b1..17e0213 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -979,6 +979,9 @@ void FastSaxParserImpl::produce( CallbackType aType )
 
 bool FastSaxParserImpl::hasNamespaceURL( const OUString& rPrefix ) const
 {
+    if (maEntities.empty())
+        return false;
+
     const Entity& rEntity = getEntity();
 
     if (rEntity.maNamespaceCount.empty())


More information about the Libreoffice-commits mailing list