File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -3752,6 +3752,26 @@ class TestBufferOverrun : public TestFixture {
37523752 " memset(&i[1], 0, 1000);\n "
37533753 " }" );
37543754 TODO_ASSERT_EQUALS (" [test.cpp:3:10]: (error) Buffer is accessed out of bounds: &i[1] [bufferAccessOutOfBounds]\n " , " " , errout_str ());
3755+
3756+ check (" struct S { int x; };\n " // #8616
3757+ " void f() {\n "
3758+ " S s;\n "
3759+ " memset(&s, 0, sizeof(s) * 2);\n "
3760+ " }\n " );
3761+ ASSERT_EQUALS (" [test.cpp:4:12]: (error) Buffer is accessed out of bounds: &s [bufferAccessOutOfBounds]\n " , errout_str ());
3762+
3763+ check (" void f() {\n "
3764+ " char x;\n "
3765+ " memset(&x, 0, 16);\n "
3766+ " }\n "
3767+ " void g(char y) {\n "
3768+ " char x;\n "
3769+ " memcpy(&x, &y, 16);\n "
3770+ " }\n " );
3771+ ASSERT_EQUALS (" [test.cpp:3:12]: (error) Buffer is accessed out of bounds: &x [bufferAccessOutOfBounds]\n "
3772+ " [test.cpp:7:12]: (error) Buffer is accessed out of bounds: &x [bufferAccessOutOfBounds]\n "
3773+ " [test.cpp:7:16]: (error) Buffer is accessed out of bounds: &y [bufferAccessOutOfBounds]\n " ,
3774+ errout_str ());
37553775 }
37563776
37573777 void valueflow_string () { // using ValueFlow string values in checking
You can’t perform that action at this time.
0 commit comments