#2540: added missing testcase.

This commit is contained in:
Ettl Martin 2012-04-26 13:16:46 +02:00
parent 30e8e389a7
commit 8494df74e6
1 changed files with 17 additions and 0 deletions

View File

@ -340,6 +340,7 @@ private:
TEST_CASE(jmp);
TEST_CASE(trac1949);
TEST_CASE(trac2540);
// #2662: segfault because of endless recursion (call_func -> getAllocationType -> functionReturnType -> call_func ..)
TEST_CASE(trac2662);
@ -3705,6 +3706,22 @@ private:
ASSERT_EQUALS("[test.cpp:10]: (error) Memory leak: buff\n", errout.str());
}
void trac2540() {
check("void f()\n"
"{\n"
" char* str = strdup(\"abc def\");\n"
" char *name = strtok(str, \" \");\n"
"}\n");
ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: str\n", errout.str());
check("void f(char *cBuf)\n"
"{\n"
" char* str = strdup(*cBuf);\n"
" char *name = strtok(str, \" \");\n"
"}\n");
ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: str\n", errout.str());
}
void trac2662() {
// segfault because of endless recursion
// call_func -> getAllocationType -> functionReturnType -> call_func ..