Fixed #5510 (FP: nullPointer - variable initialized in function call)

This commit is contained in:
Daniel Marjamäki 2014-04-01 07:06:20 +02:00
parent e0574feabd
commit 830249d72e
2 changed files with 13 additions and 0 deletions

View File

@ -61,6 +61,12 @@ static bool bailoutFunctionPar(const Token *tok, const ValueFlow::Value &value,
else
return false;
// reinterpret_cast etc..
if (Token::Match(tok->tokAt(-3), "> ( & %var% ) [,)]") &&
tok->linkAt(-3) &&
Token::Match(tok->linkAt(-3)->tokAt(-2), "[,(] %type% <"))
tok = tok->linkAt(-3);
// goto start of function call and get argnr
unsigned int argnr = 0;
while (tok && tok->str() != "(") {

View File

@ -513,6 +513,13 @@ private:
"}";
ASSERT_EQUALS(false, testValueOfX(code, 4U, 0));
code = "void f() {\n"
" char *x = 0;\n"
" getx(reinterpret_cast<void **>(&x));\n"
" *x = 0;\n"
"}";
ASSERT_EQUALS(false, testValueOfX(code, 4U, 0));
// if/else
code = "void f() {\n"
" int x = 123;\n"