wasm loader: Fix push_frame_offset when pushing v128 type (#3588)

Fixes issue https://github.com/bytecodealliance/wasm-micro-runtime/issues/3580.
This commit is contained in:
Wenyong Huang
2024-07-03 15:18:42 +08:00
committed by GitHub
parent e3074dc496
commit 1f94cd4ee5
2 changed files with 32 additions and 21 deletions

View File

@ -4869,6 +4869,8 @@ wasm_loader_push_frame_offset(WASMLoaderContext *ctx, uint8 type,
bool disable_emit, int16 operand_offset,
char *error_buf, uint32 error_buf_size)
{
uint32 cell_num_to_push, i;
if (type == VALUE_TYPE_VOID)
return true;
@ -4893,19 +4895,23 @@ wasm_loader_push_frame_offset(WASMLoaderContext *ctx, uint8 type,
if (is_32bit_type(type))
return true;
if (ctx->p_code_compiled == NULL) {
if (!check_offset_push(ctx, error_buf, error_buf_size))
return false;
}
cell_num_to_push = wasm_value_type_cell_num(type) - 1;
for (i = 0; i < cell_num_to_push; i++) {
if (ctx->p_code_compiled == NULL) {
if (!check_offset_push(ctx, error_buf, error_buf_size))
return false;
}
ctx->frame_offset++;
if (!disable_emit) {
ctx->dynamic_offset++;
if (ctx->dynamic_offset > ctx->max_dynamic_offset) {
ctx->max_dynamic_offset = ctx->dynamic_offset;
bh_assert(ctx->max_dynamic_offset < INT16_MAX);
ctx->frame_offset++;
if (!disable_emit) {
ctx->dynamic_offset++;
if (ctx->dynamic_offset > ctx->max_dynamic_offset) {
ctx->max_dynamic_offset = ctx->dynamic_offset;
bh_assert(ctx->max_dynamic_offset < INT16_MAX);
}
}
}
return true;
}