#2667 added perror to checkmemoryleak white list; added unit-tests.
This commit is contained in:
parent
f242cb639e
commit
78bcb07e19
|
@ -53,7 +53,7 @@ static const char * const call_func_white_list[] =
|
|||
, "fwrite", "getc", "gets", "gmtime", "gmtime_r", "if", "ioctl"
|
||||
, "localtime", "localtime_r"
|
||||
, "lockf", "lseek", "lstat", "memchr", "memcmp", "memcpy", "memmove", "memset"
|
||||
, "posix_fadvise", "posix_fallocate", "pread"
|
||||
, "perror", "posix_fadvise", "posix_fallocate", "pread"
|
||||
, "printf", "puts", "pwrite", "qsort", "read", "readahead", "readdir", "readdir_r", "readv"
|
||||
, "realloc", "return", "rewind", "rewinddir", "scandir", "scanf", "seekdir"
|
||||
, "setbuf", "setbuffer", "setlinebuf", "setvbuf", "snprintf", "sprintf", "sscanf", "stat", "strcasecmp"
|
||||
|
|
|
@ -571,7 +571,7 @@ private:
|
|||
, "flock", "for", "fprintf", "fputc", "fputs", "fread", "free", "freopen", "fscanf", "fseek"
|
||||
, "fseeko", "fsetpos", "fstat", "fsync", "ftell", "ftello", "ftruncate"
|
||||
, "fwrite", "getc", "if", "ioctl", "lockf", "lseek", "memchr", "memcpy"
|
||||
, "memmove", "memset", "posix_fadvise", "posix_fallocate", "pread"
|
||||
, "memmove", "memset", "perror", "posix_fadvise", "posix_fallocate", "pread"
|
||||
, "printf", "puts", "pwrite", "read", "readahead", "readdir", "readdir_r", "readv"
|
||||
, "realloc", "return", "rewind", "rewinddir", "scandir", "seekdir"
|
||||
, "setbuf", "setbuffer", "setlinebuf", "setvbuf", "snprintf", "sprintf", "strcasecmp"
|
||||
|
@ -2004,6 +2004,27 @@ private:
|
|||
" return;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// checking perror
|
||||
//http://www.cplusplus.com/reference/clibrary/cstdio/perror/
|
||||
// ---------------------------------------------------------
|
||||
|
||||
check("void foo()\n"
|
||||
"{\n"
|
||||
" char *cBuf = new char[11];\n"
|
||||
" sprintf(cBuf,\"%s\",\"testtest..\");\n"
|
||||
" perror (cBuf);\n"
|
||||
" delete [] cBuf;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo()\n"
|
||||
"{\n"
|
||||
" char *cBuf = new char[11];\n"
|
||||
" sprintf(cBuf,\"%s\",\"testtest..\");\n"
|
||||
" perror (cBuf);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:6]: (error) Memory leak: cBuf\n", errout.str());
|
||||
}
|
||||
|
||||
// # 2668
|
||||
|
|
Loading…
Reference in New Issue