Support allocation of array of pointers with operator new in checkmemoryleak.cpp

This commit is contained in:
PKEuS 2014-09-27 11:24:27 +02:00
parent 812bc6bdaf
commit e1218cf846
2 changed files with 4 additions and 3 deletions

View File

@ -153,9 +153,9 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::getAllocationType(const Token *tok2,
Token::Match(tok2, "new ( nothrow ) struct| %type% [;()]"))
return New;
if (Token::Match(tok2, "new struct| %type% [") ||
Token::Match(tok2, "new ( std :: nothrow ) struct| %type% [") ||
Token::Match(tok2, "new ( nothrow ) struct| %type% ["))
if (Token::Match(tok2, "new struct| %type% *| [") ||
Token::Match(tok2, "new ( std :: nothrow ) struct| %type% *| [") ||
Token::Match(tok2, "new ( nothrow ) struct| %type% *| ["))
return NewArray;
if (Token::Match(tok2, "fopen|tmpfile|g_fopen ("))

View File

@ -410,6 +410,7 @@ private:
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[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("const int * const a = new int[10];", "a"));
ASSERT_EQUALS(";;alloc;", getcode("int i = open(a,b);", "i"));