Memory leak : Fixed a regression and added a test case

This commit is contained in:
Daniel Marjamäki 2009-01-03 07:40:09 +00:00
parent f099796a10
commit b756158644
2 changed files with 25 additions and 9 deletions

View File

@ -261,18 +261,13 @@ const char * CheckMemoryLeakClass::call_func( const TOKEN *tok, std::list<const
}*/
const char *ret = 0;
if (TOKEN::findmatch(func_, "goto"))
{
// TODO : "goto" isn't handled well
if ( TOKEN::findmatch(func_, "dealloc") )
ret = "dealloc";
else if ( TOKEN::findmatch(func_, "use") )
ret = "use";
}
else if ( TOKEN::findmatch(func_, "dealloc") )
// TODO : "goto" isn't handled well
if ( TOKEN::findmatch(func_, "dealloc") )
ret = "dealloc";
else if ( TOKEN::findmatch(func_, "use") )
ret = "use";
else if ( TOKEN::findmatch(func_, "&use") )
ret = "&use";
Tokenizer::deleteTokens(func);
return ret;

View File

@ -127,6 +127,7 @@ private:
TEST_CASE( func9 ); // Embedding the function call in a if-condition
TEST_CASE( func10 ); // Bug 2458510 - Function pointer
TEST_CASE( func11 ); // Bug 2458510 - Function pointer
TEST_CASE( func12 );
TEST_CASE( class1 );
TEST_CASE( class2 );
@ -1036,6 +1037,26 @@ private:
ASSERT_EQUALS( std::string(""), errout.str() );
}
void func12()
{
check( "void add_list(struct mmtimer *n)\n"
"{\n"
" rb_link_node(&n->list, parent, link);\n"
"}\n"
"\n"
"int foo()\n"
"{\n"
" struct mmtimer *base;\n"
"\n"
" base = kmalloc(sizeof(struct mmtimer), GFP_KERNEL);\n"
" if (base == NULL)\n"
" return -ENOMEM;\n"
"\n"
" add_list(base);\n"
"}\n" );
ASSERT_EQUALS( std::string(""), errout.str() );
}
/*
void func3()