Support allocation of array of pointers with operator new in checkmemoryleak.cpp
This commit is contained in:
parent
812bc6bdaf
commit
e1218cf846
|
@ -153,9 +153,9 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::getAllocationType(const Token *tok2,
|
||||||
Token::Match(tok2, "new ( nothrow ) struct| %type% [;()]"))
|
Token::Match(tok2, "new ( nothrow ) struct| %type% [;()]"))
|
||||||
return New;
|
return New;
|
||||||
|
|
||||||
if (Token::Match(tok2, "new struct| %type% [") ||
|
if (Token::Match(tok2, "new struct| %type% *| [") ||
|
||||||
Token::Match(tok2, "new ( std :: nothrow ) struct| %type% [") ||
|
Token::Match(tok2, "new ( std :: nothrow ) struct| %type% *| [") ||
|
||||||
Token::Match(tok2, "new ( nothrow ) struct| %type% ["))
|
Token::Match(tok2, "new ( nothrow ) struct| %type% *| ["))
|
||||||
return NewArray;
|
return NewArray;
|
||||||
|
|
||||||
if (Token::Match(tok2, "fopen|tmpfile|g_fopen ("))
|
if (Token::Match(tok2, "fopen|tmpfile|g_fopen ("))
|
||||||
|
|
|
@ -410,6 +410,7 @@ private:
|
||||||
ASSERT_EQUALS(";;alloc;", getcode("int *a = malloc(100);", "a"));
|
ASSERT_EQUALS(";;alloc;", getcode("int *a = malloc(100);", "a"));
|
||||||
ASSERT_EQUALS(";;alloc;", getcode("int *a = new int;", "a"));
|
ASSERT_EQUALS(";;alloc;", getcode("int *a = new int;", "a"));
|
||||||
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 **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("int i = open(a,b);", "i"));
|
ASSERT_EQUALS(";;alloc;", getcode("int i = open(a,b);", "i"));
|
||||||
|
|
Loading…
Reference in New Issue