Use constant instead of magic number for AST recursion limit

[ci skip]
This commit is contained in:
Daniel Marjamäki 2014-04-15 06:31:09 +02:00
parent cb830cb999
commit 4b6164087e
1 changed files with 7 additions and 1 deletions

View File

@ -31,6 +31,12 @@
#include <stack>
// How many compileExpression recursions are allowed?
// For practical code this could be endless. But in some special torture test
// there needs to be a limit.
static const unsigned int AST_MAX_DEPTH = 50U;
TokenList::TokenList(const Settings* settings) :
_front(0),
_back(0),
@ -702,7 +708,7 @@ static void compileComma(Token *&tok, std::stack<Token*> &op, unsigned int depth
static void compileExpression(Token *&tok, std::stack<Token*> &op, unsigned int depth)
{
if (depth > 300)
if (depth > AST_MAX_DEPTH)
return; // ticket #5592
if (tok)
compileComma(tok,op, depth+1U);