File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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..
You can’t perform that action at this time.
0 commit comments