Fixed #1128 (false positive: Data is allocated but not initialized)
This commit is contained in:
parent
c05aebbc0a
commit
566cfce8da
|
@ -1361,7 +1361,7 @@ private:
|
|||
return &tok;
|
||||
}
|
||||
|
||||
if (Token::Match(tok.next(), "= malloc|kmalloc|new"))
|
||||
if (Token::Match(tok.next(), "= malloc|kmalloc") || Token::simpleMatch(tok.next(), "= new char ["))
|
||||
{
|
||||
alloc_pointer(checks, tok.varId());
|
||||
}
|
||||
|
|
|
@ -1256,6 +1256,13 @@ private:
|
|||
"};\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Data is allocated but not initialized: s1\n", errout.str());
|
||||
|
||||
checkUninitVar("void f()\n"
|
||||
"{\n"
|
||||
" Fred *fred = new Fred;\n"
|
||||
" fred->foo();\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// struct..
|
||||
checkUninitVar("void f()\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue