Fixed false positive #5848
This commit is contained in:
parent
e3009bdd0b
commit
01a0154daa
|
@ -2762,7 +2762,7 @@ void CheckMemoryLeakNoVar::check()
|
||||||
void CheckMemoryLeakNoVar::checkForUnusedReturnValue(const Scope *scope)
|
void CheckMemoryLeakNoVar::checkForUnusedReturnValue(const Scope *scope)
|
||||||
{
|
{
|
||||||
for (const Token *tok = scope->classStart; tok != scope->classEnd; tok = tok->next()) {
|
for (const Token *tok = scope->classStart; tok != scope->classEnd; tok = tok->next()) {
|
||||||
if (Token::Match(tok, "{|}|; %var% (")) {
|
if (Token::Match(tok, "{|}|; %var% (") && tok->strAt(-1) != "=") {
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
const int allocationId = _settings->library.alloc(tok);
|
const int allocationId = _settings->library.alloc(tok);
|
||||||
if (allocationId > 0)
|
if (allocationId > 0)
|
||||||
|
|
|
@ -6345,6 +6345,12 @@ private:
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("char** x(const char* str) {\n"
|
||||||
|
" char* ptr[] = { malloc(10), malloc(5), strdup(str) };\n"
|
||||||
|
" return ptr;\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("void x()\n"
|
check("void x()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" 42,malloc(42);\n"
|
" 42,malloc(42);\n"
|
||||||
|
|
Loading…
Reference in New Issue