Fix hang on huge array (followup to #11649) (#5094)

* Fix hang on huge array

* Fix another hang
This commit is contained in:
chrchr-github 2023-05-31 20:56:12 +02:00 committed by GitHub
parent 238cf75f6f
commit a32fb63443
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -942,7 +942,7 @@ static void setTokenValue(Token* tok,
if (Token::simpleMatch(parent, "-") && value2.bound == result.bound &&
value2.bound != ValueFlow::Value::Bound::Point)
result.invertBound();
setTokenValue(parent, result, settings);
setTokenValue(parent, result, settings, isInitList);
}
}
}
@ -1363,7 +1363,7 @@ static void valueFlowNumber(TokenList *tokenlist, const Settings* settings)
bool isInitList = false;
const Token* endInit{};
for (Token *tok = tokenlist->front(); tok;) {
if (!isInitList && tok->str() == "{" && Token::simpleMatch(tok->astOperand1(), ",")) {
if (!isInitList && tok->str() == "{" && (Token::simpleMatch(tok->astOperand1(), ",") || Token::simpleMatch(tok->astOperand2(), ","))) {
isInitList = true;
endInit = tok->link();
}