Fix FP leakNoVarFunctionCall with passthrough returns (#3249)
This commit is contained in:
parent
be95e2bf21
commit
bfa26b5a72
|
@ -996,7 +996,7 @@ void CheckMemoryLeakNoVar::checkForUnreleasedInputArgument(const Scope *scope)
|
||||||
const Token* tok2 = tok->next()->astParent();
|
const Token* tok2 = tok->next()->astParent();
|
||||||
while (tok2 && tok2->isCast())
|
while (tok2 && tok2->isCast())
|
||||||
tok2 = tok2->astParent();
|
tok2 = tok2->astParent();
|
||||||
if (tok2 && tok2->isAssignmentOp())
|
if (Token::Match(tok2, "%assign%|return"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const std::string& functionName = tok->str();
|
const std::string& functionName = tok->str();
|
||||||
|
|
|
@ -2174,6 +2174,11 @@ private:
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("char *x() {\n"
|
||||||
|
" return strcpy(malloc(10), \"abc\");\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("void x() {\n"
|
check("void x() {\n"
|
||||||
" free(malloc(10));\n"
|
" free(malloc(10));\n"
|
||||||
"}");
|
"}");
|
||||||
|
|
Loading…
Reference in New Issue