Uninitialized variables: fixed false negative when using uninitialized variable inside malloc call
This commit is contained in:
parent
1ec49430e3
commit
37ae4692bb
|
@ -2960,7 +2960,7 @@ private:
|
|||
{
|
||||
alloc_pointer(checks, tok.varId());
|
||||
if (tok.tokAt(3)->str() == "(")
|
||||
return tok.tokAt(3)->link();
|
||||
return tok.tokAt(3);
|
||||
}
|
||||
|
||||
else if (Token::simpleMatch(tok.previous(), ">>") || Token::simpleMatch(tok.next(), "="))
|
||||
|
|
|
@ -1176,6 +1176,13 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: p\n", errout.str());
|
||||
|
||||
checkUninitVar("void f(Foo *p)\n"
|
||||
"{\n"
|
||||
" int a;\n"
|
||||
" p->a = malloc(4 * a);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: a\n", errout.str());
|
||||
|
||||
checkUninitVar("static void foo()\n"
|
||||
"{\n"
|
||||
" int *p;\n"
|
||||
|
|
Loading…
Reference in New Issue