Skip to content

Commit 06b408e

Browse files
Fix FP leakNoVarFunctionCall with unknown function (#4242)
* Fix #10857 FN: leakNoVarFunctionCall * Fix TODO * Fix #10858 FN: leakNoVarFunctionCall (if ( b && malloc ) ) * #11155 FN: leakNoVarFunctionCall (ternary operator) * Fix #11157 FN: leakNoVarFunctionCall (switch condition) * Fix FN constStatement * Fix FP leakNoVarFunctionCall * Fix FP leakNoVarFunctionCall * Format * Fix FP leakNoVarFunctionCall with unknown function
1 parent b90a726 commit 06b408e

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

lib/checkmemoryleak.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,8 @@ void CheckMemoryLeakNoVar::checkForUnreleasedInputArgument(const Scope *scope)
10111011
functionName == "return")
10121012
continue;
10131013

1014+
if (!tok->isKeyword() && mSettings->library.isNotLibraryFunction(tok))
1015+
continue;
10141016
if (!CheckMemoryLeakInFunction::test_white_list(functionName, mSettings, mTokenizer->isCPP()))
10151017
continue;
10161018

test/testmemleak.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2415,6 +2415,18 @@ class TestMemleakNoVar : public TestFixture {
24152415
" return *strings_.insert(it, std::strcpy(new char[std::strlen(s) + 1], s));\n"
24162416
"}\n");
24172417
ASSERT_EQUALS("", errout.str());
2418+
2419+
check("struct S {\n"
2420+
" static void load(const QString & projPath) {\n"
2421+
" if (proj_)\n"
2422+
" return;\n"
2423+
" proj_ = new ProjectT(projPath);\n"
2424+
" proj_->open(new OpenCallback());\n"
2425+
" }\n"
2426+
"private:\n"
2427+
" static Core::ProjectBase* proj_;\n"
2428+
"};\n");
2429+
ASSERT_EQUALS("", errout.str());
24182430
}
24192431

24202432
void missingAssignment() {

0 commit comments

Comments
 (0)