Fixed #1138 (improve check: dereferencing uninitialized pointer)
This commit is contained in:
parent
c3886a5803
commit
738987a686
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue