Memory leaks: small fixes. add checking of 'g_fopen'. don't let 'fclose' calls be interpreted as 'callfunc'

This commit is contained in:
Daniel Marjamäki 2010-05-29 21:56:18 +02:00
parent 495dfde32c
commit 0c6352a826
2 changed files with 3 additions and 2 deletions

View File

@ -44,7 +44,7 @@ CheckMemoryLeakStructMember instance3;
static const char * const call_func_white_list[] =
{
"asctime", "asctime_r", "asprintf", "atof", "atoi", "atol", "clearerr"
, "ctime", "ctime_r", "delete", "fchmod", "fcntl"
, "ctime", "ctime_r", "delete", "fchmod", "fclose", "fcntl"
, "fdatasync", "feof", "ferror", "fflush", "fgetc", "fgetpos", "fgets"
, "flock", "for", "fprintf", "fputc", "fputs", "fread", "free", "fscanf", "fseek"
, "fseeko", "fsetpos", "fstat", "fsync", "ftell", "ftello", "ftruncate"
@ -148,7 +148,7 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::getAllocationType(const Token *tok2,
Token::Match(tok2, "new ( nothrow ) %type% ["))
return NewArray;
if (Token::Match(tok2, "fopen|tmpfile ("))
if (Token::Match(tok2, "fopen|tmpfile|g_fopen ("))
return File;
if (Token::Match(tok2, "open|openat|creat|mkstemp|mkostemp ("))

View File

@ -452,6 +452,7 @@ private:
ASSERT_EQUALS(";;dealloc;", getcode("char *s; delete [] (s);", "s"));
ASSERT_EQUALS(";;dealloc;", getcode("void *p; foo(fclose(p));", "p"));
ASSERT_EQUALS(";;dealloc;", getcode("void *p; foo(close(p));", "p"));
ASSERT_EQUALS(";;;;", getcode("FILE *f1; FILE *f2; fclose(f1);", "f2"));
// if..
ASSERT_EQUALS(";;if{}", getcode("char *s; if (a) { }", "s"));