Fixed #1128 (false positive: Data is allocated but not initialized)

This commit is contained in:
Daniel Marjamäki 2009-12-22 21:00:52 +01:00
parent c05aebbc0a
commit 566cfce8da
2 changed files with 8 additions and 1 deletions

View File

@ -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());
}

View File

@ -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"