CheckMemoryLeakInFunction: More sensitive checking when the code calls an unknown function
This commit is contained in:
parent
f28dec1f5a
commit
8715ba1458
|
@ -1353,6 +1353,14 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok, bool &all)
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete "callfunc ;" that is followed by "use|if|callfunc"
|
||||||
|
// If the function doesn't throw exception or exit the application, then the "callfunc" is not needed
|
||||||
|
if (Token::Match(tok2, "callfunc ; use|if|callfunc"))
|
||||||
|
{
|
||||||
|
tok2->deleteThis();
|
||||||
|
done = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Delete second case in "case ; case ;"
|
// Delete second case in "case ; case ;"
|
||||||
while (Token::simpleMatch(tok2, "case ; case ;"))
|
while (Token::simpleMatch(tok2, "case ; case ;"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1960,8 +1960,8 @@ private:
|
||||||
" a();\n"
|
" a();\n"
|
||||||
" if (b) return;\n"
|
" if (b) return;\n"
|
||||||
" delete [] p;\n"
|
" delete [] p;\n"
|
||||||
"}\n", true);
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:5]: (all) Memory leak: p\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: p\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue