Refine the stack frame size check in interpreter (#1730)
Limit max_stack_cell_num/max_csp_num to be no larger than UINT16_MAX, and don't check all_cell_num in interpreter again. And refine some codes in interpreter.
This commit is contained in:
@ -3594,8 +3594,10 @@ wasm_loader_push_frame_ref(WASMLoaderContext *ctx, uint8 type, char *error_buf,
|
||||
return false;
|
||||
*ctx->frame_ref++ = type;
|
||||
ctx->stack_cell_num++;
|
||||
if (ctx->stack_cell_num > ctx->max_stack_cell_num)
|
||||
if (ctx->stack_cell_num > ctx->max_stack_cell_num) {
|
||||
ctx->max_stack_cell_num = ctx->stack_cell_num;
|
||||
bh_assert(ctx->max_stack_cell_num <= UINT16_MAX);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -3661,8 +3663,10 @@ wasm_loader_push_frame_csp(WASMLoaderContext *ctx, uint8 label_type,
|
||||
#endif
|
||||
ctx->frame_csp++;
|
||||
ctx->csp_num++;
|
||||
if (ctx->csp_num > ctx->max_csp_num)
|
||||
if (ctx->csp_num > ctx->max_csp_num) {
|
||||
ctx->max_csp_num = ctx->csp_num;
|
||||
bh_assert(ctx->max_csp_num <= UINT16_MAX);
|
||||
}
|
||||
return true;
|
||||
fail:
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user