Fixed #2830 (false positive: resource leak when using fdopen)
This commit is contained in:
parent
d80a55267c
commit
47a15b6486
|
@ -51,7 +51,7 @@ static const char * const call_func_white_list[] =
|
|||
, "atof", "atoi", "atol", "chdir", "chmod", "chown"
|
||||
, "clearerr", "creat", "ctime", "ctime_r", "delete", "execl", "execle"
|
||||
, "execlp", "execv", "execve", "fchmod", "fclose", "fcntl"
|
||||
, "fdatasync", "fdopen", "feof", "ferror", "fflush", "fgetc", "fgetpos", "fgets"
|
||||
, "fdatasync", "feof", "ferror", "fflush", "fgetc", "fgetpos", "fgets"
|
||||
, "flock", "fmemopen", "fnmatch", "fopen", "fopencookie", "for", "fprintf", "fputc", "fputs", "fread", "free"
|
||||
, "freopen", "fscanf", "fseek", "fseeko", "fsetpos", "fstat", "fsync", "ftell", "ftello"
|
||||
, "ftruncate", "fwrite", "getc", "getenv","getgrnam", "gethostbyaddr", "gethostbyname", "getnetbyname"
|
||||
|
|
|
@ -315,6 +315,7 @@ private:
|
|||
TEST_CASE(getc_function);
|
||||
|
||||
TEST_CASE(open_function);
|
||||
TEST_CASE(open_fdopen);
|
||||
TEST_CASE(creat_function);
|
||||
TEST_CASE(close_function);
|
||||
TEST_CASE(fd_functions);
|
||||
|
@ -586,7 +587,7 @@ private:
|
|||
, "_open", "_wopen", "vscanf", "vsscanf", "vfscanf", "vasprintf", "utime", "utimes", "unlink"
|
||||
, "tempnam", "system", "symlink", "strpbrk", "strncasecmp", "strdup", "strcspn", "strcoll"
|
||||
, "setlocale", "sethostname", "rmdir", "rindex", "rename", "remove", "adjtime", "creat", "execle"
|
||||
, "execl", "execlp", "execve", "execv", "fdopen", "fmemopen", "fnmatch", "fopencookie", "fopen"
|
||||
, "execl", "execlp", "execve", "execv", "fmemopen", "fnmatch", "fopencookie", "fopen"
|
||||
, "getgrnam", "gethostbyaddr", "getnetbyname", "getopt", "getopt_long", "getprotobyname", "getpwnam"
|
||||
, "getservbyname", "getservbyport", "glob", "index", "inet_addr", "inet_aton", "inet_network"
|
||||
, "initgroups", "link", "mblen", "mbstowcs", "mbtowc", "mkdir", "mkfifo", "mknod", "obstack_printf"
|
||||
|
@ -3343,6 +3344,18 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void open_fdopen()
|
||||
{
|
||||
// Ticket #2830
|
||||
check("void f(const char *path)\n"
|
||||
"{\n"
|
||||
" int fd = open(path, O_RDONLY);\n"
|
||||
" FILE *f = fdopen(fd, x);\n"
|
||||
" fclose(f);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void creat_function()
|
||||
{
|
||||
check("void f(const char *path)\n"
|
||||
|
|
Loading…
Reference in New Issue