testbufferoverrun: Removed duplicate test case.

This commit is contained in:
Martin Ettl 2015-07-30 22:42:45 +02:00
parent 249a05126b
commit 42a406ac5f
1 changed files with 47 additions and 73 deletions

View File

@ -349,14 +349,6 @@ private:
void array_index_2() { void array_index_2() {
check("void f()\n"
"{\n"
" char *str = new char[0x10];\n"
" str[15] = 0;\n"
" str[16] = 0;\n"
"}");
ASSERT_EQUALS("[test.cpp:5]: (error) Array 'str[16]' accessed at index 16, which is out of bounds.\n", errout.str());
check("void a(int i)\n" // valueflow check("void a(int i)\n" // valueflow
"{\n" "{\n"
" char *str = new char[0x10];\n" " char *str = new char[0x10];\n"
@ -368,7 +360,6 @@ private:
void array_index_3() { void array_index_3() {
{
check("void f()\n" check("void f()\n"
"{\n" "{\n"
" int val[50];\n" " int val[50];\n"
@ -377,9 +368,7 @@ private:
" sum += val[i];\n" " sum += val[i];\n"
"}"); "}");
ASSERT_EQUALS("[test.cpp:6]: (error) Array 'val[50]' accessed at index 99, which is out of bounds.\n", errout.str()); ASSERT_EQUALS("[test.cpp:6]: (error) Array 'val[50]' accessed at index 99, which is out of bounds.\n", errout.str());
}
{
check("void f()\n" check("void f()\n"
"{\n" "{\n"
" int val[50];\n" " int val[50];\n"
@ -388,10 +377,7 @@ private:
" sum += val[i];\n" " sum += val[i];\n"
"}"); "}");
ASSERT_EQUALS("[test.cpp:6]: (error) Array 'val[50]' accessed at index 99, which is out of bounds.\n", errout.str()); ASSERT_EQUALS("[test.cpp:6]: (error) Array 'val[50]' accessed at index 99, which is out of bounds.\n", errout.str());
}
{
check("void f(int a)\n" check("void f(int a)\n"
"{\n" "{\n"
" int val[50];\n" " int val[50];\n"
@ -400,9 +386,7 @@ private:
" sum += val[i];\n" " sum += val[i];\n"
"}"); "}");
ASSERT_EQUALS("[test.cpp:6]: (error) Array 'val[50]' accessed at index 99, which is out of bounds.\n", errout.str()); ASSERT_EQUALS("[test.cpp:6]: (error) Array 'val[50]' accessed at index 99, which is out of bounds.\n", errout.str());
}
{
check("typedef struct g g2[3];\n" check("typedef struct g g2[3];\n"
"void foo(char *a)\n" "void foo(char *a)\n"
"{\n" "{\n"
@ -412,20 +396,14 @@ private:
" }\n" " }\n"
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
}
{
check("void foo(int argc)\n" check("void foo(int argc)\n"
"{\n" "{\n"
" char a[2];\n" " char a[2];\n"
" for (int i = 4; i < argc; i++)\n" " for (int i = 4; i < argc; i++){}\n"
" {\n"
" }\n"
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
}
{
check("void foo(int a[10]) {\n" check("void foo(int a[10]) {\n"
" for (int i=0;i<50;++i) {\n" " for (int i=0;i<50;++i) {\n"
" a[i] = 0;\n" " a[i] = 0;\n"
@ -433,7 +411,6 @@ private:
"}"); "}");
ASSERT_EQUALS("[test.cpp:3]: (error) Array 'a[10]' accessed at index 49, which is out of bounds.\n", errout.str()); ASSERT_EQUALS("[test.cpp:3]: (error) Array 'a[10]' accessed at index 49, which is out of bounds.\n", errout.str());
} }
}
void array_index_6() { void array_index_6() {
check("struct ABC\n" check("struct ABC\n"
@ -656,7 +633,7 @@ private:
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
// #2097.. // #2097
check("void foo(int *p)\n" check("void foo(int *p)\n"
"{\n" "{\n"
" --p;\n" " --p;\n"
@ -671,7 +648,6 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
void array_index_11() { void array_index_11() {
check("class ABC\n" check("class ABC\n"
"{\n" "{\n"
@ -692,7 +668,6 @@ private:
ASSERT_EQUALS("[test.cpp:13]: (error) Array 'abc.str[10]' accessed at index 10, which is out of bounds.\n", errout.str()); ASSERT_EQUALS("[test.cpp:13]: (error) Array 'abc.str[10]' accessed at index 10, which is out of bounds.\n", errout.str());
} }
void array_index_12() { void array_index_12() {
check("class Fred\n" check("class Fred\n"
"{\n" "{\n"
@ -994,8 +969,7 @@ private:
ASSERT_EQUALS("[test.cpp:3]: (error) Array index -1 is out of bounds.\n", errout.str()); ASSERT_EQUALS("[test.cpp:3]: (error) Array index -1 is out of bounds.\n", errout.str());
} }
void array_index_25() { void array_index_25() { // #1536
// ticket #1536
check("void foo()\n" check("void foo()\n"
"{\n" "{\n"
" long l[SOME_SIZE];\n" " long l[SOME_SIZE];\n"