Fixed #727 (False positive: Resource leak when release is done inside function call)
This commit is contained in:
parent
3c5b13a276
commit
af5a695f82
|
@ -534,7 +534,7 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
|
|||
--parlevel;
|
||||
if (parlevel < 1)
|
||||
{
|
||||
return _settings->_showAll ? 0 : "callfunc";
|
||||
return (_settings && _settings->_showAll) ? 0 : "callfunc";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1073,6 +1073,13 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
|||
|
||||
else
|
||||
{
|
||||
if (varid > 0 && Token::Match(tok, "%var% ( fclose|pclose ( %varid% ) ) ;", varid))
|
||||
{
|
||||
addtoken("dealloc");
|
||||
tok = tok->next()->link();
|
||||
continue;
|
||||
}
|
||||
|
||||
const char *str = call_func(tok, callstack, varid, alloctype, dealloctype, all, sz);
|
||||
if (str)
|
||||
{
|
||||
|
|
|
@ -339,6 +339,7 @@ private:
|
|||
TODO_ASSERT_EQUALS(";;dealloc;", getcode("char *s; delete (void *)(s);", "s"));
|
||||
ASSERT_EQUALS(";;dealloc;", getcode("char *s; delete [] s;", "s"));
|
||||
ASSERT_EQUALS(";;dealloc;", getcode("char *s; delete [] (s);", "s"));
|
||||
ASSERT_EQUALS(";;dealloc;", getcode("void *p; foo(fclose(p));", "p"));
|
||||
|
||||
// if..
|
||||
ASSERT_EQUALS(";;if{}", getcode("char *s; if (a) { }", "s"));
|
||||
|
|
Loading…
Reference in New Issue