Fixed #2196 (False positive: Invalid data is allocated but not initialized (initialization in loop))
This commit is contained in:
parent
a06a1a6574
commit
bf15236b9e
|
@ -677,7 +677,7 @@ private:
|
|||
}
|
||||
|
||||
// it is possible that the variable is initialized here
|
||||
if (Token::Match(tok2->previous(), "[(,] %var% [,)]"))
|
||||
if (Token::Match(tok2->previous(), "[(,] %var% [+-,)]"))
|
||||
bailouts.insert(tok2->varId());
|
||||
|
||||
// array initialization..
|
||||
|
|
|
@ -1178,6 +1178,14 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: f\n", errout.str());
|
||||
|
||||
checkUninitVar("void f()\n"
|
||||
"{\n"
|
||||
" char *p = malloc(10);\n"
|
||||
" read(p + 1);\n"
|
||||
" return p;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar("void f()\n"
|
||||
"{\n"
|
||||
" Abc *p;\n"
|
||||
|
|
Loading…
Reference in New Issue