memory leak: fixed false positive about using variable after it is released

This commit is contained in:
Daniel Marjamäki 2009-01-14 16:21:54 +00:00
parent 9e91f75386
commit 2d58b2b9ee
1 changed files with 1539 additions and 1521 deletions

View File

@ -1,4 +1,4 @@
/*
/*
* cppcheck - c/c++ syntax checking
* Copyright (C) 2007-2009 Daniel Marjamäki, Reijo Tomperi, Nicolas Le Cam
*
@ -605,9 +605,27 @@ Token *CheckMemoryLeakClass::getcode(const Token *tok, std::list<const Token *>
// Investigate function calls..
if (Token::Match(tok, "%var% ("))
{
// Inside class function.. if the var is passed as a parameter then
// just add a "use"
if (classmember)
{
addtoken("use");
int parlevel = 1;
for (const Token *tok2 = tok->tokAt(2); tok2; tok2 = tok2->next())
{
if (tok2->str() == "(")
++parlevel;
else if (tok2->str() == ")")
{
--parlevel;
if (parlevel <= 0)
break;
}
if (tok2->str() == varnameStr)
{
addtoken("use");
break;
}
}
}
else