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% ("))
|
if (Token::Match(&tok, "%var% ("))
|
||||||
{
|
{
|
||||||
// reading 1st parameter..
|
// 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));
|
use_array(foundError, checks, tok.tokAt(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
// reading 2nd parameter..
|
// reading 2nd parameter..
|
||||||
if (Token::Match(&tok, "strcpy ( %any% , %var% ) ") ||
|
if (Token::Match(&tok, "strcpy|strstr ( %any% , %var% ) ") ||
|
||||||
Token::Match(&tok, "strncpy ( %any% , %var% ,"))
|
Token::Match(&tok, "strncpy ( %any% , %var% ,"))
|
||||||
{
|
{
|
||||||
use_array(foundError, checks, tok.tokAt(4));
|
use_array(foundError, checks, tok.tokAt(4));
|
||||||
|
|
|
@ -1233,6 +1233,13 @@ private:
|
||||||
"};\n");
|
"};\n");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: s\n", errout.str());
|
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"
|
checkUninitVar("void f()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" char s[20];\n"
|
" char s[20];\n"
|
||||||
|
|
Loading…
Reference in New Issue