Fixed #2185 (False negative: when constant is undefined a 'dangerous usage of strncpy' is not found)
This commit is contained in:
parent
41bbe5d0cf
commit
624ce205b9
|
@ -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);
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue