Fixed #2065 (false positive: memory leak)
This commit is contained in:
parent
6a52538a9a
commit
80069f016e
|
@ -2134,9 +2134,9 @@ const Token *CheckMemoryLeakInFunction::findleak(const Token *tokens)
|
|||
return result->tokAt(2);
|
||||
}
|
||||
|
||||
if ((result = Token::findmatch(tokens, "alloc ; if assign ;")) != NULL)
|
||||
if ((result = Token::findmatch(tokens, "; alloc ; if assign ;")) != NULL)
|
||||
{
|
||||
return result->tokAt(3);
|
||||
return result->tokAt(4);
|
||||
}
|
||||
|
||||
if (((result = Token::findmatch(tokens, "; alloc ; if dealloc ; }")) != NULL) &&
|
||||
|
|
|
@ -812,6 +812,7 @@ private:
|
|||
ASSERT_EQUALS(2, dofindleak("if alloc;\n return;"));
|
||||
ASSERT_EQUALS(notfound, dofindleak("if alloc;\n return use;"));
|
||||
ASSERT_EQUALS(notfound, dofindleak("if alloc;\n use;"));
|
||||
ASSERT_EQUALS(notfound, dofindleak("if alloc;\n if assign;\n if dealloc; }"));
|
||||
|
||||
// if..
|
||||
ASSERT_EQUALS(notfound, dofindleak("alloc; ifv dealloc;"));
|
||||
|
@ -832,7 +833,7 @@ private:
|
|||
// assign..
|
||||
ASSERT_EQUALS(2, dofindleak("alloc;\n assign;\n dealloc;"));
|
||||
ASSERT_EQUALS(notfound, dofindleak("alloc;\n if(!var) assign;\n dealloc;"));
|
||||
ASSERT_EQUALS(2, dofindleak("alloc;\n if assign;\n dealloc;"));
|
||||
ASSERT_EQUALS(2, dofindleak(";alloc;\n if assign;\n dealloc;"));
|
||||
|
||||
// loop..
|
||||
TODO_ASSERT_EQUALS(1, dofindleak("; loop { alloc ; if break; dealloc ; }"));
|
||||
|
|
Loading…
Reference in New Issue