Fixed #5433 (FP:Possible null pointer dereference)

This commit is contained in:
Daniel Marjamäki 2014-01-31 15:43:34 +01:00
parent 9aa9530e0d
commit b3bfd5014d
2 changed files with 10 additions and 0 deletions

View File

@ -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) {

View File

@ -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"