Fixed #2129 (Invalid dereference after release report)
This commit is contained in:
parent
893f7fa347
commit
27235f27ae
|
@ -676,7 +676,16 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
|
|||
return 0;
|
||||
}
|
||||
|
||||
return "use_";
|
||||
// is the varid a parameter?
|
||||
for (const Token *tok2 = tok->tokAt(2); tok2; tok2 = tok2->next())
|
||||
{
|
||||
if (tok2->str() == "(" || tok2->str() == ")")
|
||||
break;
|
||||
if (tok2->varId() == varid)
|
||||
return "use_";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (noreturn.find(tok->str()) != noreturn.end())
|
||||
|
|
|
@ -2280,6 +2280,13 @@ private:
|
|||
" strcpy(str, p);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Dereferencing 'str' after it is deallocated / released\n", errout.str());
|
||||
|
||||
check("void foo(int x) {\n"
|
||||
" char *str = malloc(10);\n"
|
||||
" free(str);\n"
|
||||
" assert(x);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue