CheckMemoryLeak: Fix FP when overloaded new is used
This commit is contained in:
parent
4a3ece5847
commit
642cc57428
|
@ -123,6 +123,8 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::getAllocationType(const Token *tok2,
|
|||
return Malloc;
|
||||
|
||||
if (tokenizer->isCPP() && tok2->str() == "new") {
|
||||
if (tok2->strAt(1) == "(" && !Token::Match(tok2->next(),"( std| ::| nothrow )"))
|
||||
return No;
|
||||
if (tok2->astOperand1() && (tok2->astOperand1()->str() == "[" || (tok2->astOperand1()->astOperand1() && tok2->astOperand1()->astOperand1()->str() == "[")))
|
||||
return NewArray;
|
||||
return New;
|
||||
|
|
|
@ -410,6 +410,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(";;assign;", getcode("A * a = new (X) A;", "a"));
|
||||
ASSERT_EQUALS(";;alloc;", getcode("int i = open(a,b);", "i"));
|
||||
ASSERT_EQUALS(";;assign;", getcode("int i = open();", "i"));
|
||||
|
||||
|
|
Loading…
Reference in New Issue