Memory leaks: skipping function call inside allocation

This commit is contained in:
Daniel Marjamäki 2010-06-06 11:22:59 +02:00
parent a9196e8710
commit e140ff6e84
2 changed files with 7 additions and 1 deletions

View File

@ -941,6 +941,12 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
}
alloctype = alloc;
if (Token::Match(tok, "%var% = %type% ("))
{
tok = tok->tokAt(3)->link();
continue;
}
}
// assignment..

View File

@ -427,7 +427,7 @@ private:
ASSERT_EQUALS(";;alloc;", getcode("int *a = new int[10];", "a"));
ASSERT_EQUALS(";;alloc;", getcode("int * const a = new int[10];", "a"));
ASSERT_EQUALS(";;alloc;", getcode("const int * const a = new int[10];", "a"));
ASSERT_EQUALS(";;alloc;", getcode("char *a = g_strdup_printf(\"ab\");", "a"));
ASSERT_EQUALS(";;alloc;", getcode("char *a = g_strdup_printf(\"%i\", f());", "a"));
// alloc; return use;
ASSERT_EQUALS(";;alloc;returnuse;", getcode("int *a = new int[10]; return a;", "a"));