Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/checkmemoryleak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,8 @@ void CheckMemoryLeakInClass::variable(const Scope *scope, const Token *tokVarnam
}
continue;
}
if (!func.functionScope) // defaulted destructor
continue;
bool body = false;
const Token *end = func.functionScope->bodyEnd;
for (const Token *tok = func.arg->link(); tok != end; tok = tok->next()) {
Expand Down
12 changes: 12 additions & 0 deletions test/testmemleak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ class TestMemleakInClass : public TestFixture {
TEST_CASE(class23); // ticket #3303
TEST_CASE(class24); // ticket #3806 - false positive in copy constructor
TEST_CASE(class25); // ticket #4367 - false positive implementation for destructor is not seen
TEST_CASE(class26); // ticket #10789

TEST_CASE(staticvar);

Expand Down Expand Up @@ -1450,6 +1451,17 @@ class TestMemleakInClass : public TestFixture {
ASSERT_EQUALS("", errout.str());
}

void class26() { // ticket #10789 - crash
check("class C;\n"
"struct S {\n"
" S() { p = new C; }\n"
" ~S();\n"
" C* p;\n"
"};\n"
"S::~S() = default;\n");
ASSERT_EQUALS("[test.cpp:5]: (style) Class 'S' is unsafe, 'S::p' can leak by wrong usage.\n", errout.str());
}

void staticvar() {
check("class A\n"
"{\n"
Expand Down