sax/source/fastparser/fastparser.cxx | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
New commits: commit 3e525f8f880f841cab5ac28325d04b3f92607f9a Author: Kohei Yoshida <[email protected]> Date: Wed Dec 3 19:41:04 2014 -0500 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 diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx index 83bd7da..d0d6979 100644 --- a/sax/source/fastparser/fastparser.cxx +++ b/sax/source/fastparser/fastparser.cxx @@ -718,6 +718,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 ); @@ -739,11 +741,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); @@ -784,33 +786,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) _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
