Memory leaks: don't translate 'return p[10];' to 'return use ;'
This commit is contained in:
parent
33bf8bf730
commit
6d94c4f15e
|
@ -1266,7 +1266,8 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
|||
|
||||
else if (varid && Token::Match(tok, "return &| %varid%", varid))
|
||||
{
|
||||
addtoken("use");
|
||||
if (!Token::Match(tok, "return %var% ["))
|
||||
addtoken("use");
|
||||
}
|
||||
|
||||
else if (varid && Token::Match(tok, "return strcpy|strncpy|memcpy ( %varid%", varid))
|
||||
|
|
|
@ -453,6 +453,7 @@ private:
|
|||
|
||||
// alloc; return;
|
||||
ASSERT_EQUALS(";;alloc;return;", getcode("char *s = new char[100]; return 0;", "s"));
|
||||
ASSERT_EQUALS(";;alloc;return;", getcode("char *s = new char[100]; return s[0];", "s"));
|
||||
|
||||
// lock/unlock..
|
||||
ASSERT_EQUALS(";;alloc;", getcode("int a; __cppcheck_lock();", ""));
|
||||
|
|
Loading…
Reference in New Issue