mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-07-15 16:58:34 +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;
|
uint32 top;
|
||||||
|
|
||||||
/* Elements of the vector. */
|
/* Elements of the vector. */
|
||||||
uint16 elem[1];
|
uint32 elem[1];
|
||||||
} UintStack;
|
} UintStack;
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -424,6 +424,11 @@ collect_distances(RegallocContext *rc, JitBasicBlock *basic_block)
|
||||||
if (!uint_stack_push(&(rc_get_vr(rc, *regp))->distances, distance))
|
if (!uint_stack_push(&(rc_get_vr(rc, *regp))->distances, distance))
|
||||||
return -1;
|
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++;
|
distance++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user