diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index cbb2a20ef..517d9fddc 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -1011,6 +1011,8 @@ void CheckMemoryLeakNoVar::checkForUnreleasedInputArgument(const Scope *scope) functionName == "return") continue; + if (!tok->isKeyword() && mSettings->library.isNotLibraryFunction(tok)) + continue; if (!CheckMemoryLeakInFunction::test_white_list(functionName, mSettings, mTokenizer->isCPP())) continue; diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 176482c7b..fbcba2795 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -2415,6 +2415,18 @@ private: " return *strings_.insert(it, std::strcpy(new char[std::strlen(s) + 1], s));\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + check("struct S {\n" + " static void load(const QString & projPath) {\n" + " if (proj_)\n" + " return;\n" + " proj_ = new ProjectT(projPath);\n" + " proj_->open(new OpenCallback());\n" + " }\n" + "private:\n" + " static Core::ProjectBase* proj_;\n" + "};\n"); + ASSERT_EQUALS("", errout.str()); } void missingAssignment() {