Skip to content

Commit 98b27b1

Browse files
committed
fix wasm_mini_loader.c
1 parent 9bc33a0 commit 98b27b1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

core/iwasm/interpreter/wasm_mini_loader.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4342,6 +4342,15 @@ check_offset_pop(WASMLoaderContext *ctx, uint32 cells)
43424342
return true;
43434343
}
43444344

4345+
static bool
4346+
check_dynamic_offset_pop(WASMLoaderContext *ctx, uint32 cells)
4347+
{
4348+
if (ctx->dynamic_offset < 0
4349+
|| (ctx->dynamic_offset > 0 && (uint32)ctx->dynamic_offset < cells))
4350+
return false;
4351+
return true;
4352+
}
4353+
43454354
static void
43464355
free_label_patch_list(BranchBlock *frame_csp)
43474356
{
@@ -5256,7 +5265,8 @@ wasm_loader_pop_frame_offset(WASMLoaderContext *ctx, uint8 type,
52565265
return true;
52575266

52585267
ctx->frame_offset -= cell_num_to_pop;
5259-
if ((*(ctx->frame_offset) > ctx->start_dynamic_offset)
5268+
if (check_dynamic_offset_pop(ctx, cell_num_to_pop)
5269+
&& (*(ctx->frame_offset) > ctx->start_dynamic_offset)
52605270
&& (*(ctx->frame_offset) < ctx->max_dynamic_offset))
52615271
ctx->dynamic_offset -= cell_num_to_pop;
52625272

0 commit comments

Comments
 (0)