Fixed ticket #324 (Teach about fcloseall() function)

http://apps.sourceforge.net/trac/cppcheck/ticket/324
This commit is contained in:
Slava Semushin 2009-05-22 21:47:40 +07:00
parent b2aaf5d4c7
commit a2a6eebb01
2 changed files with 13 additions and 1 deletions

View File

@ -188,7 +188,8 @@ CheckMemoryLeakClass::AllocType CheckMemoryLeakClass::GetDeallocationType(const
if (Token::simpleMatch(tok, std::string("g_free ( " + names + " ) ;").c_str()))
return gMalloc;
if (Token::simpleMatch(tok, std::string("fclose ( " + names + " )").c_str()))
if (Token::simpleMatch(tok, std::string("fclose ( " + names + " )").c_str()) ||
Token::simpleMatch(tok, "fcloseall ( )"))
return File;
if (Token::simpleMatch(tok, std::string("pclose ( " + names + " )").c_str()))

View File

@ -215,6 +215,7 @@ private:
TEST_CASE(stdstring);
TEST_CASE(strndup_function);
TEST_CASE(fcloseall_function);
}
@ -2177,6 +2178,16 @@ private:
ASSERT_EQUALS(std::string("[test.cpp:4]: (error) Memory leak: out\n"), errout.str());
}
void fcloseall_function()
{
check("void f()\n"
"{\n"
" FILE *f = fopen(fname, str);\n"
" fcloseall();\n"
"}\n");
ASSERT_EQUALS(std::string(""), errout.str());
}
};
REGISTER_TEST(TestMemleak)