Fix FP leakNoVarFunctionCall with passthrough returns (#3249)

This commit is contained in:
keinflue 2021-05-08 08:26:10 +00:00 committed by GitHub
parent be95e2bf21
commit bfa26b5a72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -996,7 +996,7 @@ void CheckMemoryLeakNoVar::checkForUnreleasedInputArgument(const Scope *scope)
const Token* tok2 = tok->next()->astParent();
while (tok2 && tok2->isCast())
tok2 = tok2->astParent();
if (tok2 && tok2->isAssignmentOp())
if (Token::Match(tok2, "%assign%|return"))
continue;
const std::string& functionName = tok->str();

View File

@ -2173,6 +2173,11 @@ private:
" return ret;\n"
"}");
ASSERT_EQUALS("", errout.str());
check("char *x() {\n"
" return strcpy(malloc(10), \"abc\");\n"
"}");
ASSERT_EQUALS("", errout.str());
check("void x() {\n"
" free(malloc(10));\n"