mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-07-15 08:48:33 +00:00
Fix register allocator distance integer overflow issue
This commit is contained in:
parent
2cc719e2fd
commit
081be455f6
|
@ -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++;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user