Fixed minor bugs
This commit is contained in:
parent
69d33444d4
commit
89605c0167
|
@ -606,6 +606,8 @@ void CheckVariableScope()
|
||||||
{
|
{
|
||||||
// First token of statement..
|
// First token of statement..
|
||||||
const TOKEN *tok1 = tok->next;
|
const TOKEN *tok1 = tok->next;
|
||||||
|
if ( ! tok1 )
|
||||||
|
continue;
|
||||||
|
|
||||||
if (strcmp(tok1->str,"return")==0 ||
|
if (strcmp(tok1->str,"return")==0 ||
|
||||||
strcmp(tok1->str,"delete")==0 ||
|
strcmp(tok1->str,"delete")==0 ||
|
||||||
|
|
|
@ -110,7 +110,8 @@ void FillFunctionList(const unsigned int file_id)
|
||||||
|
|
||||||
if ( Match(tok,"%var% (") )
|
if ( Match(tok,"%var% (") )
|
||||||
funcname = tok->str;
|
funcname = tok->str;
|
||||||
else if ( Match(tok, "= %var% ;") )
|
else if ( Match(tok, "= %var% ;") ||
|
||||||
|
Match(tok, "= %var% ,") )
|
||||||
funcname = tok->next->str;
|
funcname = tok->next->str;
|
||||||
|
|
||||||
if ( std::find(_usedfunc.begin(), _usedfunc.end(), funcname) == _usedfunc.end() )
|
if ( std::find(_usedfunc.begin(), _usedfunc.end(), funcname) == _usedfunc.end() )
|
||||||
|
|
|
@ -213,11 +213,13 @@ void CreateStatementList()
|
||||||
TOKEN *rs = eq->next;
|
TOKEN *rs = eq->next;
|
||||||
|
|
||||||
bool ismalloc = false;
|
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 (");
|
||||||
ismalloc |= Match(rs, "( %type% * * ) malloc (");
|
ismalloc |= Match(rs, "( %type% * * ) malloc (");
|
||||||
|
|
|
@ -720,6 +720,15 @@ static void memleak_in_function()
|
||||||
" free(a);\n"
|
" free(a);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
check( CheckMemoryLeak, __LINE__, test9, "[test.cpp:4]: Mismatching allocation and deallocation 'a'\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" );
|
||||||
|
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue