Fix register allocator distance integer overflow issue

This commit is contained in:
Wenyong Huang 2022-06-16 16:45:42 +08:00
parent 2cc719e2fd
commit 081be455f6

View File

@ -22,7 +22,7 @@ typedef struct UintStack {
uint32 top;
/* Elements of the vector. */
uint16 elem[1];
uint32 elem[1];
} UintStack;
static bool
@ -424,6 +424,11 @@ collect_distances(RegallocContext *rc, JitBasicBlock *basic_block)
if (!uint_stack_push(&(rc_get_vr(rc, *regp))->distances, distance))
return -1;
/* Integer overflow check, normally it won't happen, but
we had better add the check here */
if (distance >= INT32_MAX)
return -1;
distance++;
}