Detect "var += fclose(f)" as deallocation (fixes false positive #6016)
This commit is contained in:
parent
ccb5384645
commit
c0e2adf723
|
@ -931,7 +931,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Token::Match(tok->previous(), "[;{})=|] ::| %var%")) {
|
if (Token::Match(tok->previous(), "[;{})=|+-] ::| %var%")) {
|
||||||
if (Token::Match(tok, "%varid% ?", varid))
|
if (Token::Match(tok, "%varid% ?", varid))
|
||||||
tok = tok->tokAt(2);
|
tok = tok->tokAt(2);
|
||||||
|
|
||||||
|
|
|
@ -555,6 +555,7 @@ private:
|
||||||
ASSERT_EQUALS(";;;dealloc;assign;;", getcode(";int res; res = close(res);", "res"));
|
ASSERT_EQUALS(";;;dealloc;assign;;", getcode(";int res; res = close(res);", "res"));
|
||||||
|
|
||||||
ASSERT_EQUALS(";;dealloc;", getcode("int f; e |= fclose(f);", "f"));
|
ASSERT_EQUALS(";;dealloc;", getcode("int f; e |= fclose(f);", "f"));
|
||||||
|
ASSERT_EQUALS(";;dealloc;", getcode("int f; e += fclose(f);", "f"));
|
||||||
|
|
||||||
// fcloseall..
|
// fcloseall..
|
||||||
ASSERT_EQUALS(";;alloc;;", getcode("char *s; s = malloc(10); fcloseall();", "s"));
|
ASSERT_EQUALS(";;alloc;;", getcode("char *s; s = malloc(10); fcloseall();", "s"));
|
||||||
|
|
Loading…
Reference in New Issue