Fixed #8040 (False positive resourceLeak - handle assigned to class instead of scalar)

This commit is contained in:
Daniel Marjamäki 2017-07-08 22:28:31 +02:00
parent 6417be4a71
commit 7161daefbd
2 changed files with 5 additions and 0 deletions

View File

@ -291,6 +291,8 @@ void CheckLeakAutoVar::checkScope(const Token * const startToken,
// Possibly automatically deallocated memory // Possibly automatically deallocated memory
if (!var->typeStartToken()->isStandardType() && Token::Match(varTok, "%var% = new")) if (!var->typeStartToken()->isStandardType() && Token::Match(varTok, "%var% = new"))
continue; continue;
if (!var->isPointer() && !var->typeStartToken()->isStandardType())
continue;
} }
// allocation? // allocation?

View File

@ -1208,6 +1208,9 @@ private:
check("void f() { Fred *p = new Fred; }", true); check("void f() { Fred *p = new Fred; }", true);
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
check("void f() { Fred fred = malloc(10); }", true);
ASSERT_EQUALS("", errout.str());
} }
void throw1() { // 3987 - Execution reach a 'throw' void throw1() { // 3987 - Execution reach a 'throw'