Memory leak : Remove false positive for "if (cond1) str=strdup(); if (cond2) str=strdup();"

This commit is contained in:
Daniel Marjamäki 2008-12-28 21:24:51 +00:00
parent 6c8c4d7a63
commit c3954afdef
1 changed files with 7 additions and 0 deletions

View File

@ -697,6 +697,13 @@ void CheckMemoryLeakClass::simplifycode(TOKEN *tok)
done = false; done = false;
} }
// Two "if alloc ;" after one another.. perhaps only one of them can be executed each time
else if (!_settings._showAll && TOKEN::Match(tok2, "[;{}] if alloc ; if alloc ;"))
{
erase(tok2, tok2->tokAt(4));
done = false;
}
// TODO Make this more generic. Delete "if ; else use ; use" // TODO Make this more generic. Delete "if ; else use ; use"
else if ( TOKEN::Match(tok2, "; if ; else assign|use ; assign|use") || else if ( TOKEN::Match(tok2, "; if ; else assign|use ; assign|use") ||
TOKEN::Match(tok2, "; if assign|use ; else ; assign|use") ) TOKEN::Match(tok2, "; if assign|use ; else ; assign|use") )