Fixed #2185 (False negative: when constant is undefined a 'dangerous usage of strncpy' is not found)

This commit is contained in:
Daniel Marjamäki 2010-11-10 20:20:05 +01:00
parent 41bbe5d0cf
commit 624ce205b9
2 changed files with 9 additions and 1 deletions

View File

@ -427,7 +427,8 @@ private:
}
// Variable declaration for array..
if (Token::Match(vartok, "%type% %var% [ %num% ] ;"))
if (Token::Match(vartok, "%type% %var% [") &&
Token::simpleMatch(vartok->tokAt(2)->link(), "] ;"))
{
vartok = vartok->next();
declare(checks, vartok, tok, false, true);

View File

@ -806,6 +806,13 @@ private:
"}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: a\n", errout.str());
checkUninitVar("int f()\n"
"{\n"
" char a[SIZE+10];\n"
" char c = *a;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: a\n", errout.str());
checkUninitVar("int f()\n"
"{\n"
" char a[10];\n"