Fixed #2218 (False positive: Data is allocated but not initialized)

This commit is contained in:
Daniel Marjamäki 2010-11-27 17:34:54 +01:00
parent 03a92582ca
commit 095f725b3c
2 changed files with 8 additions and 7 deletions

View File

@ -751,12 +751,6 @@ private:
if (Token::simpleMatch(tok.next(), ".")) if (Token::simpleMatch(tok.next(), "."))
{ {
const Token *tok2 = tok.next();
while (Token::Match(tok2, ". %var%"))
tok2 = tok2->tokAt(2);
if (tok2 && tok2->str() != "=" && tok.strAt(-1) != "&")
use_pointer(checks, &tok);
else
bailOutVar(checks, tok.varId()); bailOutVar(checks, tok.varId());
return &tok; return &tok;
} }

View File

@ -999,6 +999,13 @@ private:
"};\n"); "};\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void f()\n"
"{\n"
" Fred *fred = malloc(sizeof(Fred));\n"
" x(fred->f);\n"
"};\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar("void foo(char *s)\n" checkUninitVar("void foo(char *s)\n"
"{\n" "{\n"
" char *a = malloc(100);\n" " char *a = malloc(100);\n"