summaryrefslogtreecommitdiff
path: root/sax
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-12-03 19:41:04 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-12-03 19:58:51 -0500
commit3e525f8f880f841cab5ac28325d04b3f92607f9a (patch)
treedac88a072abd27838278c280e4ac124305370a6a /sax
parent0a87740ebe2d525d7aab7dce962cf921857d4dd6 (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')
-rw-r--r--sax/source/fastparser/fastparser.cxx22
1 files changed, 12 insertions, 10 deletions
diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx
index 83bd7daa83a2..d0d6979cd749 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)