Added test case TestMemleak::free_member_in_sub_func for ticket #253

http://apps.sourceforge.net/trac/cppcheck/ticket/253
This commit is contained in:
Reijo Tomperi 2009-04-29 21:40:21 +03:00
parent ad4c7993d1
commit a8f296bb6e
1 changed files with 31 additions and 0 deletions

View File

@ -205,6 +205,7 @@ private:
TEST_CASE(vcl2); TEST_CASE(vcl2);
TEST_CASE(autoptr1); TEST_CASE(autoptr1);
TEST_CASE(free_member_in_sub_func);
} }
@ -2055,6 +2056,36 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
void free_member_in_sub_func()
{
check("class Tokenizer\n"
"{\n"
"public:\n"
" Tokenizer();\n"
" ~Tokenizer();\n"
"\n"
"private:\n"
" int *_tokens;\n"
" static void deleteTokens(int *tok);\n"
"};\n"
"\n"
"Tokenizer::Tokenizer()\n"
"{\n"
" _tokens = new int;\n"
"}\n"
"\n"
"Tokenizer::~Tokenizer()\n"
"{\n"
" deleteTokens(_tokens);\n"
" _tokens = 0;\n"
"}\n"
"\n"
"void Tokenizer::deleteTokens(int *tok)\n"
"{\n"
" delete tok;\n"
"}\n", true);
TODO_ASSERT_EQUALS("", errout.str());
}
}; };
REGISTER_TEST(TestMemleak) REGISTER_TEST(TestMemleak)