Memory leaks: localized variables
This commit is contained in:
parent
62145431a7
commit
0cc49188c0
|
@ -1526,23 +1526,25 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
||||||
|
|
||||||
void CheckMemoryLeakInFunction::simplifycode(Token *tok)
|
void CheckMemoryLeakInFunction::simplifycode(Token *tok)
|
||||||
{
|
{
|
||||||
// Replace "throw" that is not in a try block with "return"
|
|
||||||
int indentlevel = 0;
|
|
||||||
int trylevel = -1;
|
|
||||||
for (Token *tok2 = tok; tok2; tok2 = tok2->next())
|
|
||||||
{
|
{
|
||||||
if (tok2->str() == "{")
|
// Replace "throw" that is not in a try block with "return"
|
||||||
++indentlevel;
|
int indentlevel = 0;
|
||||||
else if (tok2->str() == "}")
|
int trylevel = -1;
|
||||||
|
for (Token *tok2 = tok; tok2; tok2 = tok2->next())
|
||||||
{
|
{
|
||||||
--indentlevel;
|
if (tok2->str() == "{")
|
||||||
if (indentlevel <= trylevel)
|
++indentlevel;
|
||||||
trylevel = -1;
|
else if (tok2->str() == "}")
|
||||||
|
{
|
||||||
|
--indentlevel;
|
||||||
|
if (indentlevel <= trylevel)
|
||||||
|
trylevel = -1;
|
||||||
|
}
|
||||||
|
else if (trylevel == -1 && tok2->str() == "try")
|
||||||
|
trylevel = indentlevel;
|
||||||
|
else if (trylevel == -1 && tok2->str() == "throw")
|
||||||
|
tok2->str("return");
|
||||||
}
|
}
|
||||||
else if (trylevel == -1 && tok2->str() == "try")
|
|
||||||
trylevel = indentlevel;
|
|
||||||
else if (trylevel == -1 && tok2->str() == "throw")
|
|
||||||
tok2->str("return");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert extra ";"
|
// Insert extra ";"
|
||||||
|
|
Loading…
Reference in New Issue