From 080aa7c89fa6b35d8ea8435636c5965bf01e3661 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 29 Nov 2020 20:32:45 +0000 Subject: ofz#27892 recursion too deep MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit which appeared after... commit 8c716704df4aaa83fcd198cc8d92cd3e1e542de9 tdf#38885 Remove createTextFromNode Change-Id: I741135cec946c72e6643437eb2941cf3548901bf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106845 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- starmath/source/parse.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'starmath') diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx index b558da047cc0..e1ec6e3f9d61 100644 --- a/starmath/source/parse.cxx +++ b/starmath/source/parse.cxx @@ -1266,6 +1266,8 @@ std::unique_ptr SmParser::DoRelation() if (aDepthGuard.TooDeep()) throw std::range_error("parser depth limit"); + int nDepthLimit = m_nParseDepth; + auto xFirst = DoSum(); while (TokenInGroup(TG::Relation)) { @@ -1274,7 +1276,14 @@ std::unique_ptr SmParser::DoRelation() auto xThird = DoSum(); xSNode->SetSubNodes(std::move(xFirst), std::move(xSecond), std::move(xThird)); xFirst = std::move(xSNode); + + ++m_nParseDepth; + if (aDepthGuard.TooDeep()) + throw std::range_error("parser depth limit"); } + + m_nParseDepth = nDepthLimit; + return xFirst; } -- cgit