Fixed false positive #5848

This commit is contained in:
PKEuS 2014-05-21 13:45:36 +02:00
parent e3009bdd0b
commit 01a0154daa
2 changed files with 7 additions and 1 deletions

View File

@ -2762,7 +2762,7 @@ void CheckMemoryLeakNoVar::check()
void CheckMemoryLeakNoVar::checkForUnusedReturnValue(const Scope *scope)
{
for (const Token *tok = scope->classStart; tok != scope->classEnd; tok = tok->next()) {
if (Token::Match(tok, "{|}|; %var% (")) {
if (Token::Match(tok, "{|}|; %var% (") && tok->strAt(-1) != "=") {
tok = tok->next();
const int allocationId = _settings->library.alloc(tok);
if (allocationId > 0)

View File

@ -6345,6 +6345,12 @@ private:
"}");
ASSERT_EQUALS("", errout.str());
check("char** x(const char* str) {\n"
" char* ptr[] = { malloc(10), malloc(5), strdup(str) };\n"
" return ptr;\n"
"}");
ASSERT_EQUALS("", errout.str());
check("void x()\n"
"{\n"
" 42,malloc(42);\n"