Fix crash in valueFlowForwardLifetime() (#4891)

This commit is contained in:
chrchr-github 2023-03-18 14:53:49 +01:00 committed by GitHub
parent 319baf8d0f
commit 716fcc5e96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -3854,7 +3854,7 @@ static void valueFlowForwardLifetime(Token * tok, TokenList *tokenlist, ErrorLog
valueFlowLifetimeFunction(parent->previous(), tokenlist, errorLogger, settings);
valueFlowForwardLifetime(parent, tokenlist, errorLogger, settings);
// Variable
} else if (tok->variable()) {
} else if (tok->variable() && tok->variable()->scope()) {
const Variable *var = tok->variable();
const Token *endOfVarScope = var->scope()->bodyEnd;

View File

@ -6896,6 +6896,11 @@ private:
" const C& c = C(b) ? : C(false);\n"
"};\n";
valueOfTok(code, "?");
code = "struct S {\n"
" void g(std::vector<int> (*f) () = nullptr);\n"
"};\n";
valueOfTok(code, "=");
}
void valueFlowHang() {