Kaydet (Commit) d6e97bd2 authored tarafından Caolán McNamara's avatar Caolán McNamara

ofz#4641 fix leaks with exceptions

Change-Id: I5326240fe79a5752e19d4be3032c5ced70845437
Reviewed-on: https://gerrit.libreoffice.org/46459Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst a8d2cea0
...@@ -1045,10 +1045,10 @@ SmNode *SmParser::DoExpression(bool bUseExtraSpaces) ...@@ -1045,10 +1045,10 @@ SmNode *SmParser::DoExpression(bool bUseExtraSpaces)
if (RelationArray.size() > 1) if (RelationArray.size() > 1)
{ {
std::unique_ptr<SmExpressionNode> pSNode(new SmExpressionNode(m_aCurToken)); std::unique_ptr<SmExpressionNode> xSNode(new SmExpressionNode(m_aCurToken));
pSNode->SetSubNodes(buildNodeArray(RelationArray)); xSNode->SetSubNodes(buildNodeArray(RelationArray));
pSNode->SetUseExtraSpaces(bUseExtraSpaces); xSNode->SetUseExtraSpaces(bUseExtraSpaces);
return pSNode.release(); return xSNode.release();
} }
else else
{ {
...@@ -1063,16 +1063,16 @@ SmNode *SmParser::DoRelation() ...@@ -1063,16 +1063,16 @@ SmNode *SmParser::DoRelation()
if (aDepthGuard.TooDeep()) if (aDepthGuard.TooDeep())
throw std::range_error("parser depth limit"); throw std::range_error("parser depth limit");
SmNode *pFirst = DoSum(); std::unique_ptr<SmNode> xFirst(DoSum());
while (TokenInGroup(TG::Relation)) while (TokenInGroup(TG::Relation))
{ {
std::unique_ptr<SmStructureNode> pSNode(new SmBinHorNode(m_aCurToken)); std::unique_ptr<SmStructureNode> xSNode(new SmBinHorNode(m_aCurToken));
SmNode *pSecond = DoOpSubSup(); std::unique_ptr<SmNode> xSecond(DoOpSubSup());
SmNode *pThird = DoSum(); std::unique_ptr<SmNode> xThird(DoSum());
pSNode->SetSubNodes(pFirst, pSecond, pThird); xSNode->SetSubNodes(xFirst.release(), xSecond.release(), xThird.release());
pFirst = pSNode.release(); xFirst = std::move(xSNode);
} }
return pFirst; return xFirst.release();
} }
SmNode *SmParser::DoSum() SmNode *SmParser::DoSum()
...@@ -1493,21 +1493,21 @@ SmNode *SmParser::DoTerm(bool bGroupNumberIdent) ...@@ -1493,21 +1493,21 @@ SmNode *SmParser::DoTerm(bool bGroupNumberIdent)
if ( TokenInGroup(TG::Attribute) || if ( TokenInGroup(TG::Attribute) ||
TokenInGroup(TG::FontAttr) ) TokenInGroup(TG::FontAttr) )
{ {
std::stack<SmStructureNode *> aStack; std::stack<std::unique_ptr<SmStructureNode>> aStack;
bool bIsAttr; bool bIsAttr;
while ( (bIsAttr = TokenInGroup(TG::Attribute)) while ( (bIsAttr = TokenInGroup(TG::Attribute))
|| TokenInGroup(TG::FontAttr)) || TokenInGroup(TG::FontAttr))
aStack.push(bIsAttr ? DoAttribut() : DoFontAttribut()); aStack.push(std::unique_ptr<SmStructureNode>(bIsAttr ? DoAttribut() : DoFontAttribut()));
SmNode *pFirstNode = DoPower(); std::unique_ptr<SmNode> xFirstNode(DoPower());
while (!aStack.empty()) while (!aStack.empty())
{ {
SmStructureNode *pNode = aStack.top(); std::unique_ptr<SmStructureNode> xNode = std::move(aStack.top());
aStack.pop(); aStack.pop();
pNode->SetSubNodes(nullptr, pFirstNode); xNode->SetSubNodes(nullptr, xFirstNode.release());
pFirstNode = pNode; xFirstNode = std::move(xNode);
} }
return pFirstNode; return xFirstNode.release();
} }
if (TokenInGroup(TG::Function)) if (TokenInGroup(TG::Function))
return DoFunction(); return DoFunction();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment