File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1049,6 +1049,9 @@ void CheckMemoryLeakNoVarImpl::checkForUnreleasedInputArgument(const Scope *scop
10491049 if (alloc == New || alloc == NewArray) {
10501050 const Token* typeTok = arg->next ();
10511051 bool bail = !typeTok->isStandardType () &&
1052+ (!typeTok->valueType () ||
1053+ (typeTok->valueType ()->type < ValueType::Type::SMART_POINTER &&
1054+ typeTok->valueType ()->type != ValueType::Type::POD)) &&
10521055 !mSettings .library .detectContainerOrIterator (typeTok) &&
10531056 !mSettings .library .podtype (typeTok->expressionString ());
10541057 if (bail && typeTok->type () && typeTok->type ()->classScope &&
Original file line number Diff line number Diff 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 () {
You can’t perform that action at this time.
0 commit comments