Fixed #5433 (FP:Possible null pointer dereference)
This commit is contained in:
parent
9aa9530e0d
commit
b3bfd5014d
|
@ -538,6 +538,9 @@ static void valueFlowAfterAssign(TokenList *tokenlist, ErrorLogger *errorLogger,
|
|||
std::list<ValueFlow::Value>::iterator it;
|
||||
for (it = values.begin(); it != values.end(); ++it)
|
||||
it->conditional = true;
|
||||
|
||||
if (Token::simpleMatch(tok2,"} else {"))
|
||||
tok2 = tok2->linkAt(2);
|
||||
}
|
||||
|
||||
if (tok2->varId() == varid) {
|
||||
|
|
|
@ -555,6 +555,13 @@ private:
|
|||
"}\n";
|
||||
ASSERT_EQUALS(false, testValueOfX(code, 5U, 0));
|
||||
|
||||
code = "void f() {\n"
|
||||
" X *x = getx();\n"
|
||||
" if(false) { x = 0; }\n"
|
||||
" else { x->y = 1; }\n"
|
||||
"}";
|
||||
ASSERT_EQUALS(false, testValueOfX(code, 4U, 0));
|
||||
|
||||
// multivariables
|
||||
code = "void f(int a) {\n"
|
||||
" int x = a;\n"
|
||||
|
|
Loading…
Reference in New Issue