#3888 added a testcase

This commit is contained in:
Ettl Martin 2013-04-03 08:57:26 +02:00
parent 7596282cba
commit 9f25b618dc
1 changed files with 16 additions and 0 deletions

View File

@ -348,6 +348,7 @@ private:
TEST_CASE(trac1949); TEST_CASE(trac1949);
TEST_CASE(trac2540); TEST_CASE(trac2540);
TEST_CASE(trac3888); // #3888 False negative: memory leak through member function
// #2662: segfault because of endless recursion (call_func -> getAllocationType -> functionReturnType -> call_func ..) // #2662: segfault because of endless recursion (call_func -> getAllocationType -> functionReturnType -> call_func ..)
TEST_CASE(trac2662); TEST_CASE(trac2662);
@ -3803,6 +3804,21 @@ private:
ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: str\n", errout.str()); ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: str\n", errout.str());
} }
void trac3888() {
check("class Pool{\n"
" int* GetNewObj()\n"
" {\n"
" return new int;\n"
" }\n"
"};\n"
"void foo(){\n"
" Pool pool;\n"
" int* a = pool.GetNewObj();\n"
" int* b = GetNewObj();\n"
"}");
ASSERT_EQUALS("[test.cpp:11]: (error) Memory leak: a\n", errout.str());
}
void trac2662() { void trac2662() {
// segfault because of endless recursion // segfault because of endless recursion
// call_func -> getAllocationType -> functionReturnType -> call_func .. // call_func -> getAllocationType -> functionReturnType -> call_func ..