Fix #421 (Memory leak not found when typeid() is used.)

http://sourceforge.net/apps/trac/cppcheck/ticket/421
This commit is contained in:
Reijo Tomperi 2009-10-01 11:56:59 +03:00
parent f1e1f9b8f7
commit b3ad712b61
2 changed files with 12 additions and 1 deletions

View File

@ -52,7 +52,7 @@ static const char * const call_func_white_list[] =
, "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"
, "sync_file_range", "telldir", "typeid", "while", "write", "writev"
};
static int call_func_white_list_compare(const void *a, const void *b)

View File

@ -269,6 +269,7 @@ private:
// Unknown syntax
TEST_CASE(unknownSyntax1);
TEST_CASE(knownFunctions);
}
@ -2324,6 +2325,16 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
}
void knownFunctions()
{
check("void foo()\n"
"{\n"
" int *p = new int[100];\n"
" typeid(p);\n"
"}\n");
ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: p\n", errout.str());
}
};
static TestMemleakInFunction testMemleakInFunction;