memory leaks: fixed bug. return|else are not part of a variable declaration

This commit is contained in:
Daniel Marjamäki 2009-08-29 15:20:37 +02:00
parent eb05cf904d
commit b5c6d7ba49
1 changed files with 6 additions and 3 deletions

View File

@ -627,9 +627,8 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
if (parlevel == 0 && tok->str() == ";") if (parlevel == 0 && tok->str() == ";")
addtoken(";"); addtoken(";");
if (varid && if (Token::Match(tok->previous(), "[(;{}] %varid% =", varid) ||
(Token::Match(tok->previous(), "[(;{}] %varid% =", varid) || Token::Match(tok, "asprintf ( & %varid% ,", varid))
Token::Match(tok, "asprintf ( & %varid% ,", varid)))
{ {
AllocType alloc; AllocType alloc;
@ -1782,6 +1781,10 @@ void CheckMemoryLeakInFunction::check()
if (tok->next()->str() == "static") if (tok->next()->str() == "static")
continue; continue;
// return/else is not part of a variable declaration..
if (Token::Match(tok->next(), "return|else"))
continue;
if (Token::Match(tok, "[{};] %type% * const| %var% [;=]")) if (Token::Match(tok, "[{};] %type% * const| %var% [;=]"))
{ {
const Token *vartok = tok->tokAt(tok->tokAt(3)->str() != "const" ? 3 : 4); const Token *vartok = tok->tokAt(tok->tokAt(3)->str() != "const" ? 3 : 4);