Fix #421 (Memory leak not found when typeid() is used.)
http://sourceforge.net/apps/trac/cppcheck/ticket/421
This commit is contained in:
parent
f1e1f9b8f7
commit
b3ad712b61
|
@ -52,7 +52,7 @@ static const char * const call_func_white_list[] =
|
||||||
, "setbuf", "setbuffer", "setlinebuf", "setvbuf", "snprintf", "sprintf", "strcasecmp"
|
, "setbuf", "setbuffer", "setlinebuf", "setvbuf", "snprintf", "sprintf", "strcasecmp"
|
||||||
, "strcat", "strchr", "strcmp", "strcpy", "stricmp", "strncat", "strncmp"
|
, "strcat", "strchr", "strcmp", "strcpy", "stricmp", "strncat", "strncmp"
|
||||||
, "strncpy", "strrchr", "strstr", "strtod", "strtol", "strtoul", "switch"
|
, "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)
|
static int call_func_white_list_compare(const void *a, const void *b)
|
||||||
|
|
|
@ -269,6 +269,7 @@ private:
|
||||||
|
|
||||||
// Unknown syntax
|
// Unknown syntax
|
||||||
TEST_CASE(unknownSyntax1);
|
TEST_CASE(unknownSyntax1);
|
||||||
|
TEST_CASE(knownFunctions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2324,6 +2325,16 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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;
|
static TestMemleakInFunction testMemleakInFunction;
|
||||||
|
|
Loading…
Reference in New Issue