Skip to content

Commit ee311fc

Browse files
Update testmemleak.cpp
1 parent 1aa7249 commit ee311fc

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

test/testmemleak.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2603,6 +2603,17 @@ class TestMemleakNoVar : public TestFixture {
26032603
" a.g(new int);\n"
26042604
"}\n");
26052605
ASSERT_EQUALS("", errout_str());
2606+
2607+
check("int f() {\n" // #11184
2608+
" return strlen(new char[4]{});\n"
2609+
"}\n"
2610+
"int g() {\n"
2611+
" int i = strlen(new char[4]{});\n"
2612+
" return i;\n"
2613+
"}\n");
2614+
ASSERT_EQUALS("[test.cpp:2:19]: (error) Allocation with new, strlen doesn't release it. [leakNoVarFunctionCall]\n"
2615+
"[test.cpp:5:20]: (error) Allocation with new, strlen doesn't release it. [leakNoVarFunctionCall]\n",
2616+
errout_str());
26062617
}
26072618

26082619
void missingAssignment() {

0 commit comments

Comments
 (0)