Memory leaks: don't translate 'return p[10];' to 'return use ;'

This commit is contained in:
Daniel Marjamäki 2010-08-04 20:48:20 +02:00
parent 33bf8bf730
commit 6d94c4f15e
2 changed files with 3 additions and 1 deletions

View File

@ -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))

View File

@ -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();", ""));