Fixed #5656 (false positive: (error) Possible null pointer dereference: f)
This commit is contained in:
parent
cf12f2aaac
commit
56eb717b8a
|
@ -523,7 +523,7 @@ static void valueFlowAfterAssign(TokenList *tokenlist, ErrorLogger *errorLogger,
|
|||
Token * const end = start->link();
|
||||
if (Token::findmatch(start, "%varid%", end, varid)) {
|
||||
// TODO: don't check noreturn scopes
|
||||
if (number_of_if > 0U) {
|
||||
if (number_of_if > 0U || Token::findmatch(tok2, "%varid%", start, varid)) {
|
||||
if (settings->debugwarnings)
|
||||
bailout(tokenlist, errorLogger, tok2, "variable " + var->nameToken()->str() + " is assigned in conditional code");
|
||||
break;
|
||||
|
|
|
@ -594,6 +594,15 @@ private:
|
|||
"}";
|
||||
TODO_ASSERT_EQUALS(true, false, testValueOfX(code, 4U, 32));
|
||||
|
||||
code = "void f() {\n" // #5656 - FP
|
||||
" int x = 0;\n"
|
||||
" if (!x) {\n"
|
||||
" x = getx();\n"
|
||||
" }\n"
|
||||
" y = x;\n"
|
||||
"}";
|
||||
ASSERT_EQUALS(false, testValueOfX(code, 6U, 0));
|
||||
|
||||
// multivariables
|
||||
code = "void f(int a) {\n"
|
||||
" int x = a;\n"
|
||||
|
|
Loading…
Reference in New Issue