Skip to content

Commit 185a5e1

Browse files
committed
#7682 Added regression test
1 parent 6fd916a commit 185a5e1

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

test/testbufferoverrun.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ class TestBufferOverrun : public TestFixture {
132132
TEST_CASE(array_index_49); // #8653
133133
TEST_CASE(array_index_50);
134134
TEST_CASE(array_index_51); // #3763
135+
TEST_CASE(array_index_52); // #7682
135136
TEST_CASE(array_index_multidim);
136137
TEST_CASE(array_index_switch_in_for);
137138
TEST_CASE(array_index_for_in_for); // FP: #2634
@@ -1534,6 +1535,17 @@ class TestBufferOverrun : public TestFixture {
15341535
ASSERT_EQUALS("[test.cpp:3]: (error) Array 'd[1]' accessed at index 1, which is out of bounds.\n", errout.str());
15351536
}
15361537

1538+
void array_index_52() {
1539+
check("char f(void)\n"
1540+
"{\n"
1541+
" char buf[10];\n"
1542+
" for(int i = 0, j= 11; i < j; ++i)\n"
1543+
" buf[i] = 0;\n"
1544+
" return buf[0];\n"
1545+
"}");
1546+
ASSERT_EQUALS("[test.cpp:5]: (error) Array 'buf[10]' accessed at index 10, which is out of bounds.\n", errout.str());
1547+
}
1548+
15371549
void array_index_multidim() {
15381550
check("void f()\n"
15391551
"{\n"

0 commit comments

Comments
 (0)