Fixed #1133 (Uninitialized array: strchr, strrchr, etc)
This commit is contained in:
parent
566cfce8da
commit
2bd60ab6c8
|
@ -1393,13 +1393,13 @@ private:
|
|||
if (Token::Match(&tok, "%var% ("))
|
||||
{
|
||||
// reading 1st parameter..
|
||||
if (Token::Match(&tok, "strcat|strncat|strlen ( %var%"))
|
||||
if (Token::Match(&tok, "strcat|strncat|strchr|strrchr|strstr|strlen|strdup ( %var%"))
|
||||
{
|
||||
use_array(foundError, checks, tok.tokAt(2));
|
||||
}
|
||||
|
||||
// reading 2nd parameter..
|
||||
if (Token::Match(&tok, "strcpy ( %any% , %var% ) ") ||
|
||||
if (Token::Match(&tok, "strcpy|strstr ( %any% , %var% ) ") ||
|
||||
Token::Match(&tok, "strncpy ( %any% , %var% ,"))
|
||||
{
|
||||
use_array(foundError, checks, tok.tokAt(4));
|
||||
|
|
|
@ -1233,6 +1233,13 @@ private:
|
|||
"};\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: s\n", errout.str());
|
||||
|
||||
checkUninitVar("void f()\n"
|
||||
"{\n"
|
||||
" char s[20];\n"
|
||||
" strchr(s, ' ');\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: s\n", errout.str());
|
||||
|
||||
checkUninitVar("void f()\n"
|
||||
"{\n"
|
||||
" char s[20];\n"
|
||||
|
|
Loading…
Reference in New Issue