From c14063522433306c9b7f598b623d54fefd2a443d Mon Sep 17 00:00:00 2001
From: Kohei Yoshida <kohei.yoshida@collabora.com>
Date: Mon, 30 Jun 2014 20:03:28 -0400
Subject: [PATCH 3/3] Use a new fast parser instance for each XML fragment.
Otherwise a crash ensues when the threaded XML parsing kicks in.
Change-Id: Ic41e5a29bbb860d7b63b70f2f0d8896264d9d53e
(cherry picked from commit dc93074f71f91efd8a615ad8f1a5289deb210b75)
Reviewed-on: https://gerrit.libreoffice.org/10003
Tested-by: Michael Stahl <mstahl@redhat.com>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
---
oox/source/core/xmlfilterbase.cxx | 6 +++++-
sax/source/fastparser/fastparser.cxx | 3 +++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index cf996eb..1608aed 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -158,6 +158,7 @@ struct XmlFilterBaseImpl
{
typedef RefMap< OUString, Relations > RelationsMap;
+ Reference<XComponentContext> mxContext;
FastParser maFastParser;
const OUString maBinSuffix;
const OUString maVmlSuffix;
@@ -170,6 +171,7 @@ struct XmlFilterBaseImpl
XmlFilterBaseImpl::XmlFilterBaseImpl( const Reference< XComponentContext >& rxContext ) throw( RuntimeException ) :
+ mxContext(rxContext),
maFastParser( rxContext ),
maBinSuffix( ".bin" ),
maVmlSuffix( ".vml" )
@@ -268,7 +270,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 4ddbd2a..e10ce3f 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -1042,6 +1042,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())
--
1.9.3