Fixed #1138 (improve check: dereferencing uninitialized pointer)

This commit is contained in:
Daniel Marjamäki 2009-12-27 17:20:34 +01:00
parent c3886a5803
commit 738987a686
2 changed files with 13 additions and 0 deletions

View File

@ -1673,6 +1673,12 @@ private:
ExecutionPath::bailOutVar(checks, tok.varId());
return &tok;
}
if (Token::Match(tok.tokAt(-2), "[,(=] *"))
{
use(foundError, checks, &tok);
return &tok;
}
}
return &tok;
}

View File

@ -991,6 +991,13 @@ private:
"}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: p\n", errout.str());
checkUninitVar("static void foo()\n"
"{\n"
" int *x;\n"
" int y = *x;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: x\n", errout.str());
checkUninitVar("static int foo()\n"
"{\n"
" int ret;\n"