Fixed ticket #514 (false positive:: memory leak when using comma near delete[])
http://sourceforge.net/apps/trac/cppcheck/ticket/514
This commit is contained in:
parent
37fe631639
commit
600f3a834d
|
@ -3225,6 +3225,14 @@ bool Tokenizer::simplifyComma()
|
|||
ret = true;
|
||||
break;
|
||||
}
|
||||
else if (Token::Match(tok2, "delete %var%") ||
|
||||
Token::Match(tok2, "delete [ ] %var%"))
|
||||
{
|
||||
// Handle "delete a, a = 0;"
|
||||
tok->str(";");
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
else if (Token::Match(tok2, "[;,{}()]"))
|
||||
{
|
||||
break;
|
||||
|
|
|
@ -1076,10 +1076,17 @@ private:
|
|||
{
|
||||
const char code[] = "void foo()\n"
|
||||
"{\n"
|
||||
" int *a = new int[10];\n"
|
||||
" delete [] a, a = 0;\n"
|
||||
"}\n";
|
||||
TODO_ASSERT_EQUALS(" void foo ( ) { int * a ; a = new int [ 10 ] ; delete [ ] a ; a = 0 ; }", sizeof_(code));
|
||||
ASSERT_EQUALS(" void foo ( ) { delete [ ] a ; a = 0 ; }", sizeof_(code));
|
||||
}
|
||||
|
||||
{
|
||||
const char code[] = "void foo()\n"
|
||||
"{\n"
|
||||
" delete a, a = 0;\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS(" void foo ( ) { delete a ; a = 0 ; }", sizeof_(code));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue