sax/source/expatwrap/sax_expat.cxx | 73 ++++++++++++++++--------------------- starmath/source/parse.cxx | 28 +++++++------- 2 files changed, 47 insertions(+), 54 deletions(-)
New commits: commit 6ff9b5a63f4857703ba1974cfe2c46e34e744e26 Author: Caolán McNamara <caol...@redhat.com> Date: Sun Dec 10 11:17:40 2017 +0000 ofz#4571 more Direct-leaks Change-Id: If845238c3c107a9edc95dc3663bf4c178e65ebc7 Reviewed-on: https://gerrit.libreoffice.org/46180 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx index 05412fa8e13a..4a9dd64a0bc8 100644 --- a/starmath/source/parse.cxx +++ b/starmath/source/parse.cxx @@ -1636,9 +1636,9 @@ SmStructureNode *SmParser::DoUnOper() bool bIsPostfix = eType == TFACT; std::unique_ptr<SmStructureNode> pSNode; - SmNode *pOper = nullptr, - *pExtra = nullptr, - *pArg; + std::unique_ptr<SmNode> xOper; + std::unique_ptr<SmNode> xExtra; + std::unique_ptr<SmNode> xArg; switch (eType) { @@ -1649,7 +1649,7 @@ SmStructureNode *SmParser::DoUnOper() case TNROOT : NextToken(); - pExtra = DoPower(); + xExtra.reset(DoPower()); break; case TUOPER : @@ -1657,7 +1657,7 @@ SmStructureNode *SmParser::DoUnOper() //Let the glyph know what it is... m_aCurToken.eType = TUOPER; m_aCurToken.nGroup = TG::UnOper; - pOper = DoGlyphSpecial(); + xOper.reset(DoGlyphSpecial()); break; case TPLUS : @@ -1666,7 +1666,7 @@ SmStructureNode *SmParser::DoUnOper() case TMINUSPLUS : case TNEG : case TFACT : - pOper = DoOpSubSup(); + xOper.reset(DoOpSubSup()); break; default : @@ -1674,7 +1674,7 @@ SmStructureNode *SmParser::DoUnOper() } // get argument - pArg = DoPower(); + xArg.reset(DoPower()); if (eType == TABS) { @@ -1687,27 +1687,27 @@ SmStructureNode *SmParser::DoUnOper() aNodeToken.eType = TABS; aNodeToken.cMathChar = MS_VERTLINE; - SmNode* pLeft = new SmMathSymbolNode(aNodeToken); + std::unique_ptr<SmNode> xLeft(new SmMathSymbolNode(aNodeToken)); aNodeToken.cMathChar = MS_VERTLINE; - SmNode* pRight = new SmMathSymbolNode(aNodeToken); + std::unique_ptr<SmNode> xRight(new SmMathSymbolNode(aNodeToken)); - pSNode->SetSubNodes(pLeft, pArg, pRight); + pSNode->SetSubNodes(xLeft.release(), xArg.release(), xRight.release()); } else if (eType == TSQRT || eType == TNROOT) { pSNode.reset(new SmRootNode(aNodeToken)); - pOper = new SmRootSymbolNode(aNodeToken); - pSNode->SetSubNodes(pExtra, pOper, pArg); + xOper.reset(new SmRootSymbolNode(aNodeToken)); + pSNode->SetSubNodes(xExtra.release(), xOper.release(), xArg.release()); } else { pSNode.reset(new SmUnHorNode(aNodeToken)); if (bIsPostfix) - pSNode->SetSubNodes(pArg, pOper); + pSNode->SetSubNodes(xArg.release(), xOper.release()); else // prefix operator - pSNode->SetSubNodes(pOper, pArg); + pSNode->SetSubNodes(xOper.release(), xArg.release()); } return pSNode.release(); } commit 4aa0600449b82a419ccd6ffd8d3061fbfea3d1c2 Author: Caolán McNamara <caol...@redhat.com> Date: Sun Dec 10 11:10:10 2017 +0000 ofz#4571 Direct-leak Change-Id: I1fbeec6a29854dbc80736ed442941f55bc1bb0a3 Reviewed-on: https://gerrit.libreoffice.org/46179 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/sax/source/expatwrap/sax_expat.cxx b/sax/source/expatwrap/sax_expat.cxx index 25e9c032878f..2c8466646c53 100644 --- a/sax/source/expatwrap/sax_expat.cxx +++ b/sax/source/expatwrap/sax_expat.cxx @@ -384,6 +384,28 @@ SaxExpatParser::initialize(css::uno::Sequence< css::uno::Any > const& rArguments } } +namespace +{ + class ParserCleanup + { + private: + SaxExpatParser_Impl& m_rParser; + Entity& m_rEntity; + public: + ParserCleanup(SaxExpatParser_Impl& rParser, Entity& rEntity) + : m_rParser(rParser) + , m_rEntity(rEntity) + { + } + ~ParserCleanup() + { + m_rParser.popEntity(); + //XML_ParserFree accepts a null arg + XML_ParserFree(m_rEntity.pParser); + } + }; +} + /*************** * * parseStream does Parser-startup initializations. The SaxExpatParser_Impl::parse() method does @@ -451,50 +473,21 @@ void SaxExpatParser::parseStream( const InputSource& structSource) m_pImpl->exception = SAXParseException(); m_pImpl->pushEntity( entity ); - try - { - // start the document - if( m_pImpl->rDocumentHandler.is() ) { - m_pImpl->rDocumentHandler->setDocumentLocator( m_pImpl->rDocumentLocator ); - m_pImpl->rDocumentHandler->startDocument(); - } - m_pImpl->parse(); + ParserCleanup aEnsureFree(*m_pImpl, entity); - // finish document - if( m_pImpl->rDocumentHandler.is() ) { - m_pImpl->rDocumentHandler->endDocument(); - } - } -// catch( SAXParseException &e ) -// { -// m_pImpl->popEntity(); -// XML_ParserFree( entity.pParser ); -// css::uno::Any aAny; -// aAny <<= e; -// throw SAXException( e.Message, e.Context, aAny ); -// } - catch( SAXException & ) - { - m_pImpl->popEntity(); - XML_ParserFree( entity.pParser ); - throw; - } - catch( IOException & ) - { - m_pImpl->popEntity(); - XML_ParserFree( entity.pParser ); - throw; - } - catch( css::uno::RuntimeException & ) - { - m_pImpl->popEntity(); - XML_ParserFree( entity.pParser ); - throw; + // start the document + if( m_pImpl->rDocumentHandler.is() ) { + m_pImpl->rDocumentHandler->setDocumentLocator( m_pImpl->rDocumentLocator ); + m_pImpl->rDocumentHandler->startDocument(); } - m_pImpl->popEntity(); - XML_ParserFree( entity.pParser ); + m_pImpl->parse(); + + // finish document + if( m_pImpl->rDocumentHandler.is() ) { + m_pImpl->rDocumentHandler->endDocument(); + } } void SaxExpatParser::setDocumentHandler(const css::uno::Reference< XDocumentHandler > & xHandler)
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits