Prevent overflow when parsing 32bit values
The source can carry 32bit numbers. Watch out that they are handled all the way through to the compiled results on 32bit systems.
This commit is contained in:
parent
2fab3159dd
commit
6f30813102
|
|
@ -184,11 +184,11 @@
|
|||
return T_INSTR; }
|
||||
|
||||
[0-9][0-9]* {
|
||||
yylval.numb = strtol(yytext, 0, 0);
|
||||
yylval.numb = strtoul(yytext, 0, 0);
|
||||
return T_NUMBER; }
|
||||
|
||||
"0x"[0-9a-fA-F]+ {
|
||||
yylval.numb = strtol(yytext, 0, 0);
|
||||
yylval.numb = strtoul(yytext, 0, 0);
|
||||
return T_NUMBER; }
|
||||
|
||||
/* Handle some specialized constant/literals as symbols. */
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ static struct __vpiModPath*modpath_dst = 0;
|
|||
%union {
|
||||
char*text;
|
||||
char **table;
|
||||
long numb;
|
||||
unsigned long numb;
|
||||
bool flag;
|
||||
|
||||
comp_operands_t opa;
|
||||
|
|
|
|||
|
|
@ -1102,7 +1102,7 @@ static bool of_CMPIU_the_hard_way(vthread_t thr, vvp_code_t cp)
|
|||
{
|
||||
|
||||
unsigned idx1 = cp->bit_idx[0];
|
||||
unsigned imm = cp->bit_idx[1];
|
||||
unsigned long imm = cp->bit_idx[1];
|
||||
unsigned wid = cp->number;
|
||||
if (idx1 >= 4)
|
||||
thr_check_addr(thr, idx1+wid-1);
|
||||
|
|
@ -1116,8 +1116,8 @@ static bool of_CMPIU_the_hard_way(vthread_t thr, vvp_code_t cp)
|
|||
|
||||
vvp_bit4_t eq = BIT4_0;
|
||||
for (unsigned idx = 0 ; idx < wid ; idx += 1) {
|
||||
vvp_bit4_t rv = (imm & 1)? BIT4_1 : BIT4_0;
|
||||
imm >>= 1;
|
||||
vvp_bit4_t rv = (imm & 1UL)? BIT4_1 : BIT4_0;
|
||||
imm >>= 1UL;
|
||||
|
||||
if (bit4_is_xz(lv)) {
|
||||
eq = BIT4_X;
|
||||
|
|
|
|||
Loading…
Reference in New Issue