summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-06-30 20:03:28 -0400
committerMichael Stahl <mstahl@redhat.com>2014-07-01 10:54:51 +0000
commitd074c2ada185eb849683a96348a66adb6478a778 (patch)
treee43684fda6454f2fef3606234cff9c0183297ef3
parentbe408060a5fc5177a6055b34cb0fba63256f49b0 (diff)
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/10002 Tested-by: Michael Stahl <mstahl@redhat.com> Reviewed-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r--oox/source/core/xmlfilterbase.cxx6
-rw-r--r--sax/source/fastparser/fastparser.cxx3
2 files changed, 8 insertions, 1 deletions
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index 746ba2ed913b..3b807df64d8a 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" )
@@ -274,7 +276,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 82378b1b0275..17e0213e8845 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())