summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-02-05 17:14:07 +0000
committerCaolán McNamara <caolanm@redhat.com>2021-02-09 10:07:26 +0100
commit439f386602299bfbe05efee3a00cc7614d6ecdef (patch)
treeb29cfe0efb191caf65d2a4660f09be56818bbd85
parentd87fcadc242881c39d3c49c85b9d5ef83ec6dde4 (diff)
ofz#30330 recursion too deep
Change-Id: Iaa3961cd6501f45c93bf02a42da7816d0b83097f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110489 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--starmath/source/parse.cxx8
1 files changed, 8 insertions, 0 deletions
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index 41a6d482cf8f..b4541fea8bb7 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -1314,6 +1314,8 @@ std::unique_ptr<SmNode> SmParser::DoSum()
{
DepthProtect aDepthGuard(m_nParseDepth);
+ int nDepthLimit = m_nParseDepth;
+
auto xFirst = DoProduct();
while (TokenInGroup(TG::Sum))
{
@@ -1322,7 +1324,13 @@ std::unique_ptr<SmNode> SmParser::DoSum()
auto xThird = DoProduct();
xSNode->SetSubNodes(std::move(xFirst), std::move(xSecond), std::move(xThird));
xFirst = std::move(xSNode);
+
+ ++m_nParseDepth;
+ DepthProtect bDepthGuard(m_nParseDepth);
}
+
+ m_nParseDepth = nDepthLimit;
+
return xFirst;
}