diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 7f49257d1a3..6de1ede2bf9 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -1071,7 +1071,7 @@ void CheckMemoryLeakNoVar::checkForUnreleasedInputArgument(const Scope *scope) const Variable* argvar = tok->function()->getArgumentVar(argnr); if (!argvar || !argvar->valueType()) continue; - const size_t argSize = argvar->valueType()->getSizeOf(*mSettings, ValueType::Accuracy::ExactOrZero, ValueType::SizeOf::Pointee); + const size_t argSize = argvar->valueType()->getSizeOf(*mSettings, ValueType::Accuracy::ExactOrZero, ValueType::SizeOf::Pointer); if (argSize == 0 || argSize >= mSettings->platform.sizeof_pointer) continue; } diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index ba687ad9983..406f46de902 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -2350,7 +2350,7 @@ class TestMemleakNoVar : public TestFixture { "void x() {\n" " set_error(strdup(p));\n" "}"); - ASSERT_EQUALS("[test.cpp:5:15]: (error) Allocation with strdup, set_error doesn't release it. [leakNoVarFunctionCall]\n", errout_str()); + TODO_ASSERT_EQUALS("[test.cpp:5:15]: (error) Allocation with strdup, set_error doesn't release it. [leakNoVarFunctionCall]\n", "", errout_str()); check("void f()\n" "{\n" @@ -2502,6 +2502,15 @@ class TestMemleakNoVar : public TestFixture { " f(new U());\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + check("struct A {\n" // #14339 + " void g(int* p) { p_ = p; }\n" + " int *p_;\n" + "};\n" + "void f(A& a) {\n" + " a.g(new int);\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void missingAssignment() {