Fixed #5660 (false positive: (error) Uninitialized variable: result)
This commit is contained in:
parent
59cd1879db
commit
9b1d058410
|
@ -350,7 +350,12 @@ void ExecutionPath::checkScope(const Token *tok, std::list<ExecutionPath *> &che
|
|||
return;
|
||||
}
|
||||
|
||||
tok = tok->next()->link();
|
||||
const Token * const end = tok->next()->link();
|
||||
while (tok && tok != end) {
|
||||
if (Token::Match(tok, "[{,] & %var% [,}]"))
|
||||
ExecutionPath::bailOutVar(checks, tok->tokAt(2)->varId());
|
||||
tok = tok->next();
|
||||
}
|
||||
if (!tok) {
|
||||
ExecutionPath::bailOut(checks);
|
||||
return;
|
||||
|
|
|
@ -1620,6 +1620,14 @@ private:
|
|||
ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: i\n", errout.str());
|
||||
}
|
||||
|
||||
// Ticket #5660 - False positive
|
||||
checkUninitVar("int f() {\n"
|
||||
" int result;\n"
|
||||
" int *res[] = {&result};\n"
|
||||
" foo(res);\n"
|
||||
" return result;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
// strncpy doesn't always null-terminate..
|
||||
|
|
Loading…
Reference in New Issue