Memory leaks: Testing that asprintf is handled correctly

This commit is contained in:
Daniel Marjamäki 2009-08-28 23:26:40 +02:00
parent 0f0d7e92ee
commit 74fd052fc0
2 changed files with 7 additions and 2 deletions

View File

@ -41,7 +41,7 @@ CheckMemoryLeakStructMember instance3;
// This list needs to be alphabetically sorted so we can run bsearch on it
static const char * const call_func_white_list[] =
{
"atof", "atoi", "atol", "clearerr", "delete", "fchmod", "fcntl"
"asprintf", "atof", "atoi", "atol", "clearerr", "delete", "fchmod", "fcntl"
, "fdatasync", "feof", "ferror", "fflush", "fgetc", "fgetpos", "fgets"
, "flock", "for", "fprintf", "fputc", "fputs", "fread", "fseek"
, "fseeko", "fsetpos", "fstat", "fsync", "ftell", "ftello", "ftruncate"
@ -49,7 +49,7 @@ static const char * const call_func_white_list[] =
, "memmove", "memset", "posix_fadvise", "posix_fallocate", "pread"
, "printf", "pwrite", "read", "readahead", "readdir", "readdir_r", "readv"
, "realloc", "return", "rewind", "rewinddir", "scandir", "seekdir"
, "setbuf", "setbuffer", "setlinebuf", "setvbuf", "sprintf", "strcasecmp"
, "setbuf", "setbuffer", "setlinebuf", "setvbuf", "snprintf", "sprintf", "strcasecmp"
, "strcat", "strchr", "strcmp", "strcpy", "stricmp", "strncat", "strncmp"
, "strncpy", "strrchr", "strstr", "strtod", "strtol", "strtoul", "switch"
, "sync_file_range", "telldir", "while", "write", "writev"

View File

@ -352,6 +352,11 @@ private:
ASSERT_EQUALS(";;loop{alloc;}", getcode("char *s; for (a;b;c) { s=malloc(10); }", "s"));
ASSERT_EQUALS(";;do{}loop;", getcode("char *s; do { } while (a);", "s"));
// asprintf..
TODO_ASSERT_EQUALS(";;alloc;", getcode("char *s; asprintf(&s, \"xyz\");", "s"));
TODO_ASSERT_EQUALS(";;alloc;", getcode("char *s; asprintf(&s, \"s: %s\", s);", "s"));
ASSERT_EQUALS(";;;", getcode("char *s; asprintf(&p, \"s: %s\", s);", "s"));
// use..
ASSERT_EQUALS(";;use;", getcode("char *s; DeleteString(s);", "s"));
ASSERT_EQUALS(";;use;", getcode("char *s; s2 = s;", "s"));