Skip to content

Commit 2ccefce

Browse files
Update testmemleak.cpp
1 parent ebaa7ce commit 2ccefce

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

test/testmemleak.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2613,6 +2613,21 @@ class TestMemleakNoVar : public TestFixture {
26132613
ASSERT_EQUALS("[test.cpp:2:19]: (error) Allocation with new, strlen doesn't release it. [leakNoVarFunctionCall]\n"
26142614
"[test.cpp:5:20]: (error) Allocation with new, strlen doesn't release it. [leakNoVarFunctionCall]\n",
26152615
errout_str());
2616+
2617+
check("int* f1() { return new int; }\n" // #14808
2618+
"std::string* f2() { return new std::string(\"abc\"); }\n"
2619+
"std::clock_t* f3() { return new std::clock_t; }\n"
2620+
"QWidget* f4(QObject* parent) { return new QWidget(parent); }\n"
2621+
"void g(QObject* parent) {\n"
2622+
" assert(f1());\n"
2623+
" assert(f2());\n"
2624+
" assert(f3());\n"
2625+
" assert(f4(parent));\n"
2626+
"}\n");
2627+
ASSERT_EQUALS("[test.cpp:6:12]: (error) Allocation with f1, assert doesn't release it. [leakNoVarFunctionCall]\n"
2628+
"[test.cpp:7:12]: (error) Allocation with f2, assert doesn't release it. [leakNoVarFunctionCall]\n"
2629+
"[test.cpp:8:12]: (error) Allocation with f3, assert doesn't release it. [leakNoVarFunctionCall]\n",
2630+
errout_str());
26162631
}
26172632

26182633
void missingAssignment() {

0 commit comments

Comments
 (0)