Memory leaks: skipping function call inside allocation
This commit is contained in:
parent
a9196e8710
commit
e140ff6e84
|
@ -941,6 +941,12 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
||||||
}
|
}
|
||||||
|
|
||||||
alloctype = alloc;
|
alloctype = alloc;
|
||||||
|
|
||||||
|
if (Token::Match(tok, "%var% = %type% ("))
|
||||||
|
{
|
||||||
|
tok = tok->tokAt(3)->link();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// assignment..
|
// assignment..
|
||||||
|
|
|
@ -427,7 +427,7 @@ private:
|
||||||
ASSERT_EQUALS(";;alloc;", getcode("int *a = new int[10];", "a"));
|
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("int * const a = new int[10];", "a"));
|
||||||
ASSERT_EQUALS(";;alloc;", getcode("const 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;
|
// alloc; return use;
|
||||||
ASSERT_EQUALS(";;alloc;returnuse;", getcode("int *a = new int[10]; return a;", "a"));
|
ASSERT_EQUALS(";;alloc;returnuse;", getcode("int *a = new int[10]; return a;", "a"));
|
||||||
|
|
Loading…
Reference in New Issue