getArguments: Avoid too deep recursion in array initialization
This commit is contained in:
parent
e0f1418228
commit
7995b2fb86
|
@ -1021,13 +1021,14 @@ int numberOfArguments(const Token *start)
|
||||||
return arguments;
|
return arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getArgumentsRecursive(const Token *tok, std::vector<const Token *> *arguments)
|
static void getArgumentsRecursive(const Token *tok, std::vector<const Token *> *arguments, unsigned int depth)
|
||||||
{
|
{
|
||||||
if (!tok)
|
++depth;
|
||||||
|
if (!tok || depth >= 100)
|
||||||
return;
|
return;
|
||||||
if (tok->str() == ",") {
|
if (tok->str() == ",") {
|
||||||
getArgumentsRecursive(tok->astOperand1(), arguments);
|
getArgumentsRecursive(tok->astOperand1(), arguments, depth);
|
||||||
getArgumentsRecursive(tok->astOperand2(), arguments);
|
getArgumentsRecursive(tok->astOperand2(), arguments, depth);
|
||||||
} else {
|
} else {
|
||||||
arguments->push_back(tok);
|
arguments->push_back(tok);
|
||||||
}
|
}
|
||||||
|
@ -1042,7 +1043,7 @@ std::vector<const Token *> getArguments(const Token *ftok)
|
||||||
const Token *startTok = tok->astOperand2();
|
const Token *startTok = tok->astOperand2();
|
||||||
if (!startTok && Token::simpleMatch(tok->astOperand1(), ","))
|
if (!startTok && Token::simpleMatch(tok->astOperand1(), ","))
|
||||||
startTok = tok->astOperand1();
|
startTok = tok->astOperand1();
|
||||||
getArgumentsRecursive(startTok, &arguments);
|
getArgumentsRecursive(startTok, &arguments, 0);
|
||||||
return arguments;
|
return arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue