Fix FP leakNoVarFunctionCall (#5309)

This commit is contained in:
chrchr-github 2023-08-10 20:55:02 +02:00 committed by GitHub
parent 23deadb370
commit 560982de94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -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);

View File

@ -2493,6 +2493,13 @@ private:
" 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() {