diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-02-09 09:44:31 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-02-09 12:29:03 +0100 |
commit | e2342ca5155f27637770fc392916804c8ac4728f (patch) | |
tree | 0a901d64ead29afb2e0d169416b2487defd20244 | |
parent | dc4443a3696fa13914bc47251a9d6d832eed7338 (diff) |
ofz#30663 Direct-leak
since...
commit 17149f65f03a34e88bb4a10abcd20e6891f5d7ca
Date: Sun Feb 7 10:41:46 2021 +0100
Let depthGuard handle everything
Change-Id: Icb978724000aec75a84ca6ecfd0fe9e299291db6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110623
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | starmath/inc/parse.hxx | 4 | ||||
-rw-r--r-- | starmath/source/parse.cxx | 18 |
2 files changed, 10 insertions, 12 deletions
diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx index 591db3637714..6349dc8c479f 100644 --- a/starmath/inc/parse.hxx +++ b/starmath/inc/parse.hxx @@ -148,8 +148,8 @@ class SmParser std::unique_ptr<SmNode> DoRelation(); std::unique_ptr<SmNode> DoSum(); std::unique_ptr<SmNode> DoProduct(); - std::unique_ptr<SmNode> DoSubSup(TG nActiveGroup, SmNode *pGivenNode); - std::unique_ptr<SmNode> DoSubSupEvaluate(SmNode *pGivenNode); + std::unique_ptr<SmNode> DoSubSup(TG nActiveGroup, std::unique_ptr<SmNode> xGivenNode); + std::unique_ptr<SmNode> DoSubSupEvaluate(std::unique_ptr<SmNode> xGivenNode); std::unique_ptr<SmNode> DoOpSubSup(); std::unique_ptr<SmNode> DoPower(); std::unique_ptr<SmBlankNode> DoBlank(); diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx index b4541fea8bb7..0aa1518eb4c2 100644 --- a/starmath/source/parse.cxx +++ b/starmath/source/parse.cxx @@ -1408,10 +1408,9 @@ std::unique_ptr<SmNode> SmParser::DoProduct() return xFirst; } -std::unique_ptr<SmNode> SmParser::DoSubSup(TG nActiveGroup, SmNode *pGivenNode) +std::unique_ptr<SmNode> SmParser::DoSubSup(TG nActiveGroup, std::unique_ptr<SmNode> xGivenNode) { DepthProtect aDepthGuard(m_nParseDepth); - std::unique_ptr<SmNode> xGivenNode(pGivenNode); assert(nActiveGroup == TG::Power || nActiveGroup == TG::Limit); assert(m_aCurToken.nGroup == nActiveGroup); @@ -1482,10 +1481,9 @@ std::unique_ptr<SmNode> SmParser::DoSubSup(TG nActiveGroup, SmNode *pGivenNode) return pNode; } -std::unique_ptr<SmNode> SmParser::DoSubSupEvaluate(SmNode *pGivenNode) +std::unique_ptr<SmNode> SmParser::DoSubSupEvaluate(std::unique_ptr<SmNode> xGivenNode) { DepthProtect aDepthGuard(m_nParseDepth); - std::unique_ptr<SmNode> xGivenNode(pGivenNode); std::unique_ptr<SmSubSupNode> pNode(new SmSubSupNode(m_aCurToken)); pNode->SetUseLimits(true); @@ -1535,13 +1533,13 @@ std::unique_ptr<SmNode> SmParser::DoOpSubSup() DepthProtect aDepthGuard(m_nParseDepth); // get operator symbol - auto pNode = std::make_unique<SmMathSymbolNode>(m_aCurToken); + auto xNode = std::make_unique<SmMathSymbolNode>(m_aCurToken); // skip operator token NextToken(); // get sub- supscripts if any if (m_aCurToken.nGroup == TG::Power) - return DoSubSup(TG::Power, pNode.release()); - return pNode; + return DoSubSup(TG::Power, std::move(xNode)); + return xNode; } std::unique_ptr<SmNode> SmParser::DoPower() @@ -1552,7 +1550,7 @@ std::unique_ptr<SmNode> SmParser::DoPower() std::unique_ptr<SmNode> xNode(DoTerm(false)); if (m_aCurToken.nGroup == TG::Power) - return DoSubSup(TG::Power, xNode.release()); + return DoSubSup(TG::Power, std::move(xNode)); return xNode; } @@ -1857,7 +1855,7 @@ std::unique_ptr<SmOperNode> SmParser::DoOperator() auto xOperator = DoOper(); if (m_aCurToken.nGroup == TG::Limit || m_aCurToken.nGroup == TG::Power) - xOperator = DoSubSup(m_aCurToken.nGroup, xOperator.release()); + xOperator = DoSubSup(m_aCurToken.nGroup, std::move(xOperator)); // get argument auto xArg = DoPower(); @@ -2398,7 +2396,7 @@ std::unique_ptr<SmNode> SmParser::DoEvaluate() if ( m_aCurToken.nGroup == TG::Limit ) { std::unique_ptr<SmNode> rSNode; - rSNode = DoSubSupEvaluate(xSNode.release()); + rSNode = DoSubSupEvaluate(std::move(xSNode)); rSNode->GetToken().eType = TEVALUATE; return rSNode; } |