From 74fd052fc016f8da1a86476343d99ae6027c539e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 28 Aug 2009 23:26:40 +0200 Subject: [PATCH] Memory leaks: Testing that asprintf is handled correctly --- src/checkmemoryleak.cpp | 4 ++-- test/testmemleak.cpp | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/checkmemoryleak.cpp b/src/checkmemoryleak.cpp index 72ef4baf1..e598e451c 100644 --- a/src/checkmemoryleak.cpp +++ b/src/checkmemoryleak.cpp @@ -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" diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 957a82c05..4d7a66ce3 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -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"));