Fixed false positive #5327: fclose as inner function call

This commit is contained in:
PKEuS 2014-09-30 13:55:21 +02:00
parent c0e2adf723
commit 8788e58cbb
2 changed files with 2 additions and 1 deletions

View File

@ -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(), "%op%|;|{|}|) ::| %var%") || (Token::Match(tok->previous(), "( ::| %var%") && (!rettail || rettail->str() != "loop"))) {
if (Token::Match(tok, "%varid% ?", varid))
tok = tok->tokAt(2);

View File

@ -556,6 +556,7 @@ private:
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; foo(fclose(f));", "f"));
// fcloseall..
ASSERT_EQUALS(";;alloc;;", getcode("char *s; s = malloc(10); fcloseall();", "s"));