CheckBufferOverrun: Refactoring and made the checking smarter

This commit is contained in:
Daniel Marjamäki 2008-05-10 13:48:15 +00:00
parent aef0278e43
commit ece441d952
1 changed files with 64 additions and 59 deletions

View File

@ -336,15 +336,22 @@ static void CheckBufferOverrun_StructVariable()
if ( tok2->str[0] == '}' )
break;
if ( strchr( ";{,(", tok2->str[0] ) )
{
// Declare array..
if ( Match(tok2->next, "%type% %var% [ %num% ] ;") ||
Match(tok2->next, "%type% * %var% [ %num% ] ;") )
{
const char *varname[3] = {0,0,0};
int ivar = IsName(getstr(tok2, 2)) ? 2 : 3;
if ( ! strchr( ";{,(", tok2->str[0] ) )
continue;
int ivar = 0;
if ( Match(tok2->next, "%type% %var% [ %num% ] ;") )
ivar = 2;
else if ( Match(tok2->next, "%type% %type% %var% [ %num% ] ;") )
ivar = 3;
else if ( Match(tok2->next, "%type% * %var% [ %num% ] ;") )
ivar = 3;
else if ( Match(tok2->next, "%type% %type% * %var% [ %num% ] ;") )
ivar = 4;
else
continue;
const char *varname[3] = {0,0,0};
varname[1] = getstr(tok2, ivar);
int arrsize = atoi(getstr(tok2, ivar+2));
int total_size = arrsize * SizeOfType(tok2->next->str);
@ -402,8 +409,6 @@ static void CheckBufferOverrun_StructVariable()
}
}
}
}
}
//---------------------------------------------------------------------------
void CheckBufferOverrun()