Fixed #3444 (False positive using putenv)

This commit is contained in:
Daniel Marjamäki 2011-12-29 07:35:27 +01:00
parent 90e1a397a2
commit 6d98406d71
2 changed files with 11 additions and 2 deletions

View File

@ -61,7 +61,7 @@ static const char * const call_func_white_list[] = {
, "mkdir", "mkfifo", "mknod", "mkstemp" , "mkdir", "mkfifo", "mknod", "mkstemp"
, "obstack_printf", "obstack_vprintf", "open", "opendir", "parse_printf_format", "pathconf" , "obstack_printf", "obstack_vprintf", "open", "opendir", "parse_printf_format", "pathconf"
, "perror", "popen" ,"posix_fadvise", "posix_fallocate", "pread" , "perror", "popen" ,"posix_fadvise", "posix_fallocate", "pread"
, "printf", "psignal", "putenv", "puts", "pwrite", "qsort", "read", "readahead", "readdir", "readdir_r" , "printf", "psignal", "puts", "pwrite", "qsort", "read", "readahead", "readdir", "readdir_r"
, "readlink", "readv" , "readlink", "readv"
, "realloc", "regcomp", "remove", "rename", "return", "rewind", "rewinddir", "rindex" , "realloc", "regcomp", "remove", "rename", "return", "rewind", "rewinddir", "rindex"
, "rmdir" ,"scandir", "scanf", "seekdir" , "rmdir" ,"scandir", "scanf", "seekdir"

View File

@ -222,6 +222,7 @@ private:
TEST_CASE(func23); // Ticket #2667 TEST_CASE(func23); // Ticket #2667
TEST_CASE(func24); // Ticket #2705 TEST_CASE(func24); // Ticket #2705
TEST_CASE(func25); // Ticket #2904 TEST_CASE(func25); // Ticket #2904
TEST_CASE(func26);
TEST_CASE(allocfunc1); TEST_CASE(allocfunc1);
TEST_CASE(allocfunc2); TEST_CASE(allocfunc2);
@ -589,7 +590,7 @@ private:
, "getgrnam", "gethostbyaddr", "getnetbyname", "getopt", "getopt_long", "getprotobyname", "getpwnam" , "getgrnam", "gethostbyaddr", "getnetbyname", "getopt", "getopt_long", "getprotobyname", "getpwnam"
, "getservbyname", "getservbyport", "glob", "index", "inet_addr", "inet_aton", "inet_network" , "getservbyname", "getservbyport", "glob", "index", "inet_addr", "inet_aton", "inet_network"
, "initgroups", "link", "mblen", "mbstowcs", "mbtowc", "mkdir", "mkfifo", "mknod", "obstack_printf" , "initgroups", "link", "mblen", "mbstowcs", "mbtowc", "mkdir", "mkfifo", "mknod", "obstack_printf"
, "obstack_vprintf", "opendir", "parse_printf_format", "pathconf", "popen", "psignal", "putenv" , "obstack_vprintf", "opendir", "parse_printf_format", "pathconf", "popen", "psignal"
, "readlink", "regcomp", "strxfrm", "wordexp", "sizeof", "strtok" , "readlink", "regcomp", "strxfrm", "wordexp", "sizeof", "strtok"
}; };
@ -2221,6 +2222,14 @@ private:
ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: f\n", errout.str()); ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: f\n", errout.str());
} }
void func26() { // ticket #3444
// technically there is a leak here. however warning is not wanted
check("void f() {\n"
" char *p = strdup(\"A=B\");\n"
" putenv(p);\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void allocfunc1() { void allocfunc1() {
check("static char *a()\n" check("static char *a()\n"