From 21f13f91f905d606687f113c4c0c90c6aa6c1196 Mon Sep 17 00:00:00 2001 From: Norbert Thiebaud Date: Mon, 18 Feb 2013 03:19:29 -0600 Subject: coverity#705976 coverity#7074977 Change-Id: Iaedb5fcd87a24f478d7c4a9c25e32cd2d0ee55da Reviewed-on: https://gerrit.libreoffice.org/2221 Reviewed-by: Norbert Thiebaud Tested-by: Norbert Thiebaud --- xmlsecurity/source/xmlsec/saxhelper.cxx | 53 ++++++++++++++++----------------- 1 file changed, 26 insertions(+), 27 deletions(-) (limited to 'xmlsecurity') diff --git a/xmlsecurity/source/xmlsec/saxhelper.cxx b/xmlsecurity/source/xmlsec/saxhelper.cxx index dbf1b3704702..5bac10de7c8a 100644 --- a/xmlsecurity/source/xmlsec/saxhelper.cxx +++ b/xmlsecurity/source/xmlsec/saxhelper.cxx @@ -123,21 +123,6 @@ SAXHelper::SAXHelper( ) m_pParserCtxt = xmlNewParserCtxt() ; - /* - * i41748 - * - * mmi : re-initialize the SAX handler to version 1 - */ - - xmlSAXVersion(m_pParserCtxt->sax, 1); - - /* end */ - - if( m_pParserCtxt->inputTab[0] != NULL ) - { - m_pParserCtxt->inputTab[0] = NULL ; - } - if( m_pParserCtxt == NULL ) { #ifndef XMLSEC_NO_XSLT @@ -148,25 +133,35 @@ SAXHelper::SAXHelper( ) // xmlCleanupParser() ; throw cssu::RuntimeException() ; } - else if( m_pParserCtxt->sax == NULL ) + else { - xmlFreeParserCtxt( m_pParserCtxt ) ; + xmlSAXVersion(m_pParserCtxt->sax, 1); + + if( m_pParserCtxt->inputTab[0] != NULL ) + { + m_pParserCtxt->inputTab[0] = NULL ; + } + + if( m_pParserCtxt->sax == NULL ) + { + xmlFreeParserCtxt( m_pParserCtxt ) ; #ifndef XMLSEC_NO_XSLT - xsltCleanupGlobals() ; + xsltCleanupGlobals() ; #endif // see issue i74334, we cannot call xmlCleanupParser when libxml is still used // in other parts of the office. // xmlCleanupParser() ; - m_pParserCtxt = NULL ; - throw cssu::RuntimeException() ; - } - else - { - m_pSaxHandler = m_pParserCtxt->sax ; + m_pParserCtxt = NULL ; + throw cssu::RuntimeException() ; + } + else + { + m_pSaxHandler = m_pParserCtxt->sax ; - //Adjust the context - m_pParserCtxt->recovery = 1 ; + //Adjust the context + m_pParserCtxt->recovery = 1 ; + } } } @@ -233,6 +228,10 @@ xmlDocPtr SAXHelper::getDocument() void SAXHelper::startDocument( void ) throw( cssxs::SAXException , cssu::RuntimeException ) { + if( m_pParserCtxt == NULL) + { + throw cssu::RuntimeException() ; + } /* * Adjust inputTab */ @@ -246,7 +245,7 @@ void SAXHelper::startDocument( void ) m_pSaxHandler->startDocument( m_pParserCtxt ) ; - if( m_pParserCtxt == NULL || m_pParserCtxt->myDoc == NULL ) + if( m_pParserCtxt->myDoc == NULL ) { throw cssu::RuntimeException() ; } -- cgit