Eric Sesterhenn: Fixed #1130 (False positive uninitialized variable)

This commit is contained in:
Daniel Marjamäki 2009-12-22 19:16:34 +01:00
parent b4b63789fc
commit 11da89784f
2 changed files with 10 additions and 1 deletions

View File

@ -1399,7 +1399,8 @@ private:
} }
// reading 2nd parameter.. // reading 2nd parameter..
if (Token::Match(&tok, "strcpy|strncpy ( %any% , %var%")) if (Token::Match(&tok, "strcpy ( %any% , %var% ) ") ||
Token::Match(&tok, "strncpy ( %any% , %var% ,"))
{ {
use_array(foundError, checks, tok.tokAt(4)); use_array(foundError, checks, tok.tokAt(4));
} }

View File

@ -1286,6 +1286,14 @@ private:
" int x = a;\n" " int x = a;\n"
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void f(struct blame_entry *ent)\n"
"{\n"
" struct origin *suspect = ent->suspect;\n"
" char hex[41];\n"
" strcpy(hex, sha1_to_hex(suspect->commit->object.sha1));\n"
"}\n");
ASSERT_EQUALS("", errout.str());
} }