Fix FP leakNoVarFunctionCall (#4241)
* Fix #10857 FN: leakNoVarFunctionCall * Fix TODO * Fix #10858 FN: leakNoVarFunctionCall (if ( b && malloc ) ) * #11155 FN: leakNoVarFunctionCall (ternary operator) * Fix #11157 FN: leakNoVarFunctionCall (switch condition) * Fix FN constStatement * Fix FP leakNoVarFunctionCall * Fix FP leakNoVarFunctionCall * Format
This commit is contained in:
parent
185294499c
commit
b90a726441
|
@ -998,7 +998,9 @@ 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 (Token::Match(tok2, "%assign%|return"))
|
if (Token::Match(tok2, "%assign%"))
|
||||||
|
continue;
|
||||||
|
if (Token::simpleMatch(tok->astTop(), "return"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const std::string& functionName = tok->str();
|
const std::string& functionName = tok->str();
|
||||||
|
|
|
@ -2407,6 +2407,14 @@ private:
|
||||||
ASSERT_EQUALS("[test.cpp:1]: (error) Allocation with new, if doesn't release it.\n"
|
ASSERT_EQUALS("[test.cpp:1]: (error) Allocation with new, if doesn't release it.\n"
|
||||||
"[test.cpp:2]: (error) Allocation with malloc, if doesn't release it.\n",
|
"[test.cpp:2]: (error) Allocation with malloc, if doesn't release it.\n",
|
||||||
errout.str());
|
errout.str());
|
||||||
|
|
||||||
|
check("const char* string(const char* s) {\n"
|
||||||
|
" StringSet::iterator it = strings_.find(s);\n"
|
||||||
|
" if (it != strings_.end())\n"
|
||||||
|
" return *it;\n"
|
||||||
|
" return *strings_.insert(it, std::strcpy(new char[std::strlen(s) + 1], s));\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void missingAssignment() {
|
void missingAssignment() {
|
||||||
|
|
Loading…
Reference in New Issue