Fixed minor bugs

This commit is contained in:
Daniel Marjamäki 2008-03-29 17:27:02 +00:00
parent 69d33444d4
commit 89605c0167
4 changed files with 18 additions and 4 deletions

View File

@ -606,6 +606,8 @@ void CheckVariableScope()
{
// First token of statement..
const TOKEN *tok1 = tok->next;
if ( ! tok1 )
continue;
if (strcmp(tok1->str,"return")==0 ||
strcmp(tok1->str,"delete")==0 ||

View File

@ -110,7 +110,8 @@ void FillFunctionList(const unsigned int file_id)
if ( Match(tok,"%var% (") )
funcname = tok->str;
else if ( Match(tok, "= %var% ;") )
else if ( Match(tok, "= %var% ;") ||
Match(tok, "= %var% ,") )
funcname = tok->next->str;
if ( std::find(_usedfunc.begin(), _usedfunc.end(), funcname) == _usedfunc.end() )

View File

@ -213,11 +213,13 @@ void CreateStatementList()
TOKEN *rs = eq->next;
bool ismalloc = false;
if (Match(rs, "strdup ("))
if ( Match(rs, "%var% (") )
{
ismalloc = true;
ismalloc |= Match(rs, "strdup (");
ismalloc |= Match(rs, "malloc (");
ismalloc |= Match(rs, "kmalloc (");
}
else if (rs->str[0]=='(' && IsName(getstr(rs,1)))
else
{
ismalloc |= Match(rs, "( %type% * ) malloc (");
ismalloc |= Match(rs, "( %type% * * ) malloc (");

View File

@ -720,6 +720,15 @@ static void memleak_in_function()
" free(a);\n"
"}\n";
check( CheckMemoryLeak, __LINE__, test9, "[test.cpp:4]: Mismatching allocation and deallocation 'a'\n" );
const char test10[] = "static void f()\n"
"{\n"
" struct acpi_object_list *obj_list;\n"
" obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL);\n"
"}\n";
check( CheckMemoryLeak, __LINE__, test10, "[test.cpp:5]: Memory leak:obj_list\n" );
}
//---------------------------------------------------------------------------