Merge branch 'master' of git@github.com:danmar/cppcheck
This commit is contained in:
commit
f895ab9a0d
|
@ -130,6 +130,8 @@ private:
|
|||
TEST_CASE(strncat1);
|
||||
TEST_CASE(strncat2);
|
||||
|
||||
TEST_CASE(memfunc); // memchr/memset/memcpy
|
||||
|
||||
TEST_CASE(cin1);
|
||||
|
||||
TEST_CASE(varid1);
|
||||
|
@ -1432,6 +1434,42 @@ private:
|
|||
|
||||
|
||||
|
||||
// memchr/memset/memcpy/etc
|
||||
void memfunc()
|
||||
{
|
||||
check("void f()\n"
|
||||
"{\n"
|
||||
" char str[5];\n"
|
||||
" memset(str, 0, 10);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer access out-of-bounds\n", errout.str());
|
||||
|
||||
check("void f()\n"
|
||||
"{\n"
|
||||
" char a[5], b[50];\n"
|
||||
" memcpy(a, b, 10);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer access out-of-bounds\n", errout.str());
|
||||
|
||||
check("void f()\n"
|
||||
"{\n"
|
||||
" char a[5], b[50];\n"
|
||||
" memmove(a, b, 10);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer access out-of-bounds\n", errout.str());
|
||||
|
||||
// When this TODO assertion works, ticket #909 can probably be closed
|
||||
check("void f()\n"
|
||||
"{\n"
|
||||
" char a[5], b[50];\n"
|
||||
" memchr(a, b, 10);\n"
|
||||
"}\n");
|
||||
TODO_ASSERT_EQUALS("[test.cpp:4]: (error) Buffer access out-of-bounds\n", errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void cin1()
|
||||
{
|
||||
check("#include <iostream>\n"
|
||||
|
|
Loading…
Reference in New Issue