From ebaa7ce90023d8407d919c0652fa6680a7cfa3a8 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 1 Jun 2026 15:23:29 +0200 Subject: [PATCH 1/3] Update checkmemoryleak.cpp --- lib/checkmemoryleak.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index d02bb607b33..b7888ff89ea 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -1052,6 +1052,9 @@ void CheckMemoryLeakNoVarImpl::checkForUnreleasedInputArgument(const Scope *scop if (alloc == New || alloc == NewArray) { const Token* typeTok = arg->next(); bool bail = !typeTok->isStandardType() && + (!typeTok->valueType() || + (typeTok->valueType()->type < ValueType::Type::SMART_POINTER && + typeTok->valueType()->type != ValueType::Type::POD)) && !mSettings.library.detectContainerOrIterator(typeTok) && !mSettings.library.podtype(typeTok->expressionString()); if (bail && typeTok->type() && typeTok->type()->classScope && From 2ccefce8f3e440fb32e99790b42ff54155d5790b Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 1 Jun 2026 15:24:31 +0200 Subject: [PATCH 2/3] Update testmemleak.cpp --- test/testmemleak.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 6e3d28010a1..f368b362882 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -2613,6 +2613,21 @@ class TestMemleakNoVar : public TestFixture { ASSERT_EQUALS("[test.cpp:2:19]: (error) Allocation with new, strlen doesn't release it. [leakNoVarFunctionCall]\n" "[test.cpp:5:20]: (error) Allocation with new, strlen doesn't release it. [leakNoVarFunctionCall]\n", errout_str()); + + check("int* f1() { return new int; }\n" // #14808 + "std::string* f2() { return new std::string(\"abc\"); }\n" + "std::clock_t* f3() { return new std::clock_t; }\n" + "QWidget* f4(QObject* parent) { return new QWidget(parent); }\n" + "void g(QObject* parent) {\n" + " assert(f1());\n" + " assert(f2());\n" + " assert(f3());\n" + " assert(f4(parent));\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:6:12]: (error) Allocation with f1, assert doesn't release it. [leakNoVarFunctionCall]\n" + "[test.cpp:7:12]: (error) Allocation with f2, assert doesn't release it. [leakNoVarFunctionCall]\n" + "[test.cpp:8:12]: (error) Allocation with f3, assert doesn't release it. [leakNoVarFunctionCall]\n", + errout_str()); } void missingAssignment() { From 793e68fb4e85bc4f76387b32160629593e9a3dd4 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 1 Jun 2026 17:09:30 +0200 Subject: [PATCH 3/3] Update checkmemoryleak.cpp --- lib/checkmemoryleak.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index b7888ff89ea..eceef0c5c1e 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -1054,7 +1054,7 @@ void CheckMemoryLeakNoVarImpl::checkForUnreleasedInputArgument(const Scope *scop bool bail = !typeTok->isStandardType() && (!typeTok->valueType() || (typeTok->valueType()->type < ValueType::Type::SMART_POINTER && - typeTok->valueType()->type != ValueType::Type::POD)) && + typeTok->valueType()->type != ValueType::Type::POD)) && !mSettings.library.detectContainerOrIterator(typeTok) && !mSettings.library.podtype(typeTok->expressionString()); if (bail && typeTok->type() && typeTok->type()->classScope &&