#2733 added sizeof to checkmemory-leaks white list, added a todo-testcase

This commit is contained in:
Ettl Martin 2011-04-19 16:55:27 +02:00
parent c238b1bba6
commit 47a1332e6a
2 changed files with 28 additions and 2 deletions

View File

@ -66,7 +66,7 @@ static const char * const call_func_white_list[] =
, "readlink", "readv"
, "realloc", "regcomp", "remove", "rename", "return", "rewind", "rewinddir", "rindex"
, "rmdir" ,"scandir", "scanf", "seekdir"
, "setbuf", "setbuffer", "sethostname", "setlinebuf", "setlocale" ,"setvbuf", "snprintf", "sprintf", "sscanf"
, "setbuf", "setbuffer", "sethostname", "setlinebuf", "setlocale" ,"setvbuf", "sizeof" ,"snprintf", "sprintf", "sscanf"
, "stat", "stpcpy", "strcasecmp", "strcat", "strchr", "strcmp", "strcoll"
, "strcpy", "strcspn", "strdup", "stricmp", "strlen", "strncasecmp", "strncat", "strncmp"
, "strncpy", "strpbrk","strrchr", "strspn", "strstr", "strtod", "strtol", "strtoul", "strxfrm", "switch"

View File

@ -232,6 +232,7 @@ private:
TEST_CASE(func22); // Ticket #2668
TEST_CASE(func23); // Ticket #2667
TEST_CASE(func24); // Ticket #2705
TEST_CASE(func25); // Ticket #2733
TEST_CASE(allocfunc1);
TEST_CASE(allocfunc2);
@ -589,7 +590,7 @@ private:
, "getservbyname", "getservbyport", "glob", "index", "inet_addr", "inet_aton", "inet_network"
, "initgroups", "link", "mblen", "mbstowcs", "mbtowc", "mkdir", "mkfifo", "mknod", "obstack_printf"
, "obstack_vprintf", "opendir", "parse_printf_format", "pathconf", "popen", "psignal", "putenv"
, "readlink", "regcomp", "strxfrm", "wordexp"
, "readlink", "regcomp", "strxfrm", "wordexp", "sizeof"
};
for (unsigned int i = 0; i < (sizeof(call_func_white_list) / sizeof(char *)); ++i)
@ -2199,6 +2200,31 @@ private:
ASSERT_EQUALS("", errout.str());
}
// #2733
void func25()
{
check("int* GetDeviceName(int a, int b)\n"
"{\n"
" int *p = new int[255];\n"
" memset(p, 0, 255 * sizeof(int));\n"
" if(a)\n"
" if(b)\n"
" return p;\n"
" return NULL; \n"
"}\n");
TODO_ASSERT_EQUALS("[test.cpp:8]: (error) Memory leak: p\n","", errout.str());
check("int* GetDeviceName(int a)\n"
"{\n"
" int *p = new int[255];\n"
" memset(p, 0, 255 * sizeof(int));\n"
" if(a)\n"
" return p;\n"
" return NULL; \n"
"}\n");
ASSERT_EQUALS("[test.cpp:7]: (error) Memory leak: p\n", errout.str());
}
void allocfunc1()
{
check("static char *a()\n"