Skip to content

Commit 2b61170

Browse files
Add test for #11066 (cppcheck-opensource#4136)
1 parent eefa04c commit 2b61170

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

test/testbufferoverrun.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ class TestBufferOverrun : public TestFixture {
189189
TEST_CASE(array_index_62); // #7684
190190
TEST_CASE(array_index_63); // #10979
191191
TEST_CASE(array_index_64); // #10878
192+
TEST_CASE(array_index_65); // #11066
192193
TEST_CASE(array_index_multidim);
193194
TEST_CASE(array_index_switch_in_for);
194195
TEST_CASE(array_index_for_in_for); // FP: #2634
@@ -1822,6 +1823,18 @@ class TestBufferOverrun : public TestFixture {
18221823
TODO_ASSERT_EQUALS("[test.cpp:3]: (error) Array 'x[10]' accessed at index 10, which is out of bounds.\n", "", errout.str());
18231824
}
18241825

1826+
void array_index_65() // #11066
1827+
{
1828+
check("char P[] = { 2, 1 };\n"
1829+
"char f[2];\n"
1830+
"void e(char* c) {\n"
1831+
" register j;\n"
1832+
" for (j = 0; j < 2; j++)\n"
1833+
" c[j] = f[P[j] - 1];\n"
1834+
"}\n");
1835+
ASSERT_EQUALS("", errout.str());
1836+
}
1837+
18251838
void array_index_multidim() {
18261839
check("void f()\n"
18271840
"{\n"

0 commit comments

Comments
 (0)