Skip to content

Commit

Permalink
Fix FP leakNoVarFunctionCall
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Aug 10, 2023
1 parent 23deadb commit 8342608
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/checkmemoryleak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,8 @@ void CheckMemoryLeakNoVar::checkForUnreleasedInputArgument(const Scope *scope)
const Variable* argvar = tok->function()->getArgumentVar(argnr);
if (!argvar || !argvar->valueType())
continue;
if (argvar->valueType()->typeSize(mSettings->platform, /*p*/ true) >= mSettings->platform.sizeof_pointer)
const MathLib::bigint argSize = argvar->valueType()->typeSize(mSettings->platform, /*p*/ true);
if (argSize <= 0 || argSize >= mSettings->platform.sizeof_pointer)
continue;
}
functionCallLeak(arg, arg->str(), functionName);
Expand Down
7 changes: 7 additions & 0 deletions test/testmemleak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2493,6 +2493,13 @@ class TestMemleakNoVar : public TestFixture {
" g(1, new int());\n"
"}\n");
ASSERT_EQUALS("", errout.str());

check("void f(T t);\n"
"struct U {};\n"
"void g() {\n"
" f(new U());\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}

void missingAssignment() {
Expand Down

0 comments on commit 8342608

Please sign in to comment.