fix: correct boundary check in dynamic_offset check (#4788)

correct boundary check in check_dynamic_offset_pop when dynamic_offset is 0. When dynamic_offset = 0, check_dynamic_offset_pop will always return true, which may wrongly update dynamic_offset.
also include a typo fix in SET_OPERAND_REF

Signed-off-by: zhenweijin <zhenwei.jin@intel.com>
This commit is contained in:
Zhenwei Jin 2026-01-20 08:53:11 +08:00 committed by GitHub
parent 29767f6b51
commit 23df0d4e55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3 additions and 5 deletions

View File

@ -442,7 +442,7 @@ wasm_interp_get_frame_ref(WASMInterpFrame *frame)
opnd_off = *(int16 *)(frame_ip + off); \
addr_tmp = frame_lp + opnd_off; \
PUT_REF_TO_ADDR(addr_tmp, value); \
SET_FRAME_REF(ond_off); \
SET_FRAME_REF(opnd_off); \
} while (0)
#define SET_OPERAND(op_type, off, value) SET_OPERAND_##op_type(off, value)

View File

@ -8545,8 +8545,7 @@ check_offset_pop(WASMLoaderContext *ctx, uint32 cells)
static bool
check_dynamic_offset_pop(WASMLoaderContext *ctx, uint32 cells)
{
if (ctx->dynamic_offset < 0
|| (ctx->dynamic_offset > 0 && (uint32)ctx->dynamic_offset < cells))
if (ctx->dynamic_offset < 0 || (uint32)ctx->dynamic_offset < cells)
return false;
return true;
}

View File

@ -4345,8 +4345,7 @@ check_offset_pop(WASMLoaderContext *ctx, uint32 cells)
static bool
check_dynamic_offset_pop(WASMLoaderContext *ctx, uint32 cells)
{
if (ctx->dynamic_offset < 0
|| (ctx->dynamic_offset > 0 && (uint32)ctx->dynamic_offset < cells))
if (ctx->dynamic_offset < 0 || (uint32)ctx->dynamic_offset < cells)
return false;
return true;
}