CheckBufferOverrun: Refactoring and made the checking smarter
This commit is contained in:
parent
aef0278e43
commit
ece441d952
|
@ -336,15 +336,22 @@ static void CheckBufferOverrun_StructVariable()
|
||||||
if ( tok2->str[0] == '}' )
|
if ( tok2->str[0] == '}' )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if ( strchr( ";{,(", tok2->str[0] ) )
|
if ( ! strchr( ";{,(", tok2->str[0] ) )
|
||||||
{
|
continue;
|
||||||
// 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;
|
|
||||||
|
|
||||||
|
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);
|
varname[1] = getstr(tok2, ivar);
|
||||||
int arrsize = atoi(getstr(tok2, ivar+2));
|
int arrsize = atoi(getstr(tok2, ivar+2));
|
||||||
int total_size = arrsize * SizeOfType(tok2->next->str);
|
int total_size = arrsize * SizeOfType(tok2->next->str);
|
||||||
|
@ -402,8 +409,6 @@ static void CheckBufferOverrun_StructVariable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void CheckBufferOverrun()
|
void CheckBufferOverrun()
|
||||||
|
|
Loading…
Reference in New Issue