Fixed ticket #327 (File descriptor leak not detected when feof() used)

Thanks to aggro80@ for help.

http://apps.sourceforge.net/trac/cppcheck/ticket/327
This commit is contained in:
Slava Semushin 2009-05-23 17:20:26 +07:00
parent bbf63b7970
commit b5c7316666
2 changed files with 12 additions and 1 deletions

View File

@ -214,7 +214,7 @@ const char * CheckMemoryLeakClass::call_func(const Token *tok, std::list<const T
return 0;
// I/O functions that are not allocating nor deallocating memory..
if (Token::Match(tok, "fgets|fgetc|fputs|fputc|printf"))
if (Token::Match(tok, "fgets|fgetc|fputs|fputc|feof|printf"))
return 0;
// Convert functions that are not allocating nor deallocating memory..

View File

@ -216,6 +216,7 @@ private:
TEST_CASE(strndup_function);
TEST_CASE(fcloseall_function);
TEST_CASE(feof_function);
TEST_CASE(pointer_to_pointer);
}
@ -2189,6 +2190,16 @@ private:
ASSERT_EQUALS(std::string(""), errout.str());
}
void feof_function()
{
check("void f()\n"
"{\n"
"FILE *f = fopen(fname, str);\n"
"feof(f);\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Resource leak: f\n"), errout.str());
}
void pointer_to_pointer()
{
check("void f(char **data)\n"