Skip to content

Commit 5ba9b61

Browse files
Update testuninitvar.cpp
1 parent 28d2bdc commit 5ba9b61

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

test/testuninitvar.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,6 +2139,24 @@ class TestUninitVar : public TestFixture {
21392139
" *(p + i) = 0;\n"
21402140
"}\n");
21412141
ASSERT_EQUALS("", errout_str());
2142+
2143+
checkUninitVar("int* f() {\n" // #14448
2144+
" int* p = (int*)malloc(4);\n"
2145+
" if (!p)\n"
2146+
" return nullptr;\n"
2147+
" if (*p) {}\n"
2148+
" return p;\n"
2149+
"}\n");
2150+
ASSERT_EQUALS("[test.cpp:5:9]: (error) Memory is allocated but not initialized: *p [uninitdata]\n", errout_str());
2151+
2152+
checkUninitVar("int* f() {\n"
2153+
" int* p = (int*)malloc(4);\n"
2154+
" if (p == nullptr)\n"
2155+
" return nullptr;\n"
2156+
" if (*p) {}\n"
2157+
" return p;\n"
2158+
"}\n");
2159+
ASSERT_EQUALS("[test.cpp:5:9]: (error) Memory is allocated but not initialized: *p [uninitdata]\n", errout_str());
21422160
}
21432161

21442162
// class / struct..

0 commit comments

Comments
 (0)