You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -4320,7 +4322,7 @@ class TestBufferOverrun : public TestFixture {
4320
4322
" char c;\n"
4321
4323
" mymemset(&c, 0, 4);\n"
4322
4324
"}", dinit(CheckOptions, $.s = &settings));
4323
-
TODO_ASSERT_EQUALS("[test.cpp:3:14]: (error) Buffer is accessed out of bounds: c [bufferAccessOutOfBounds]\n", "", errout_str());
4325
+
ASSERT_EQUALS("[test.cpp:3:12]: (error) Buffer is accessed out of bounds: &c [bufferAccessOutOfBounds]\n", errout_str());
4324
4326
4325
4327
// ticket #2121 - buffer access out of bounds when using uint32_t
4326
4328
check("void f(void) {\n"
@@ -5712,6 +5714,33 @@ class TestBufferOverrun : public TestFixture {
5712
5714
"}", dinit(CheckOptions, $.s = &settings));
5713
5715
ASSERT_EQUALS("", errout_str());
5714
5716
}
5717
+
5718
+
voidgetBufferSizeOfAddressOfVariable() { // #7570
5719
+
5720
+
check("void f() {\n"
5721
+
" int i;\n"
5722
+
" memset(&i, 0, 1000);\n"
5723
+
"}");
5724
+
ASSERT_EQUALS("[test.cpp:3:10]: (error) Buffer is accessed out of bounds: &i [bufferAccessOutOfBounds]\n", errout_str());
5725
+
5726
+
check("void f() {\n"
5727
+
" int i;\n"
5728
+
" memset(&i, 0, sizeof(i));\n"
5729
+
"}");
5730
+
ASSERT_EQUALS("", errout_str());
5731
+
5732
+
check("void foo() {\n"
5733
+
" char c[6];\n"
5734
+
" strncpy(&c, \"hello!\", 6);\n"
5735
+
"}");
5736
+
ASSERT_EQUALS("[test.cpp:3:3]: (warning, inconclusive) The buffer '&c' may not be null-terminated after the call to strncpy(). [terminateStrncpy]\n", errout_str());
0 commit comments