diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-12-03 19:41:04 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-12-03 19:52:23 -0500 |
commit | a09a709594dd0f6e38f8c6bf28433bd391e8842d (patch) | |
tree | 056bfcff815d6e21c426cdb5264b2f7172ac78c5 /sax/source | |
parent | f810d84663742694a12bc1517c39bfd014839d7c (diff) |
Prevent hang during loading of xlsm doc.
* We need to call xmlInitParser() before using it in a multi-threaded
way (according to the libxml2 doc).
* Better to use 'rEntity' which references the one stored in the vector
rather than 'entity' whose copy gets stored in the vector. On Windows
at least 'rEntity' and 'entity' hold different parser pointer values.
* Free the parser before popping the entity. Popping the entity first then
freeing the parser using its pointer value stored in the entity looks
weird.
Change-Id: I6b64a6d8ac9c1d4fea8339d8fb2d38dfffbba47b
Diffstat (limited to 'sax/source')
-rw-r--r-- | sax/source/fastparser/fastparser.cxx | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx index 92791fc84938..fc1f5a90ceb8 100644 --- a/sax/source/fastparser/fastparser.cxx +++ b/sax/source/fastparser/fastparser.cxx @@ -720,6 +720,8 @@ sal_Int32 FastSaxParserImpl::GetTokenWithContextNamespace( sal_Int32 nNamespaceT void FastSaxParserImpl::parseStream(const InputSource& maStructSource) throw (SAXException, IOException, RuntimeException, std::exception) { + xmlInitParser(); + // Only one text at one time MutexGuard guard( maMutex ); @@ -741,11 +743,11 @@ void FastSaxParserImpl::parseStream(const InputSource& maStructSource) try { // start the document - if( entity.mxDocumentHandler.is() ) + if( rEntity.mxDocumentHandler.is() ) { Reference< XLocator > xLoc( mxDocumentLocator.get() ); - entity.mxDocumentHandler->setDocumentLocator( xLoc ); - entity.mxDocumentHandler->startDocument(); + rEntity.mxDocumentHandler->setDocumentLocator( xLoc ); + rEntity.mxDocumentHandler->startDocument(); } rEntity.mbEnableThreads = (rEntity.maStructSource.aInputStream->available() > 10000); @@ -786,33 +788,33 @@ void FastSaxParserImpl::parseStream(const InputSource& maStructSource) } // finish document - if( entity.mxDocumentHandler.is() ) + if( rEntity.mxDocumentHandler.is() ) { - entity.mxDocumentHandler->endDocument(); + rEntity.mxDocumentHandler->endDocument(); } } catch (const SAXException&) { - popEntity(); // TODO free mpParser.myDoc ? - xmlFreeParserCtxt( entity.mpParser ); + xmlFreeParserCtxt( rEntity.mpParser ); + popEntity(); throw; } catch (const IOException&) { + xmlFreeParserCtxt( rEntity.mpParser ); popEntity(); - xmlFreeParserCtxt( entity.mpParser ); throw; } catch (const RuntimeException&) { + xmlFreeParserCtxt( rEntity.mpParser ); popEntity(); - xmlFreeParserCtxt( entity.mpParser ); throw; } + xmlFreeParserCtxt( rEntity.mpParser ); popEntity(); - xmlFreeParserCtxt( entity.mpParser ); } void FastSaxParserImpl::setFastDocumentHandler( const Reference< XFastDocumentHandler >& Handler ) throw (RuntimeException) |