diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 4eba45ab2..5f639d4e4 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -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 (")) diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 8c7060dc1..26ebae9b8 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -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"));