mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-07-15 16:58:34 +00:00
fix func type check in call_ref
This commit is contained in:
parent
f5eee38268
commit
b4571805fe
|
@ -48,7 +48,7 @@ wasm_func_type_is_subtype_of(const WASMFuncType *type1,
|
||||||
const WASMTypePtr *types, uint32 type_count);
|
const WASMTypePtr *types, uint32 type_count);
|
||||||
|
|
||||||
/* Whether func type1 is one of super types of func type2,
|
/* Whether func type1 is one of super types of func type2,
|
||||||
used for the func type check in call_indirect opcode */
|
used for the func type check in call_indirect/call_ref opcodes */
|
||||||
bool
|
bool
|
||||||
wasm_func_type_is_super_of(const WASMFuncType *type1,
|
wasm_func_type_is_super_of(const WASMFuncType *type1,
|
||||||
const WASMFuncType *type2);
|
const WASMFuncType *type2);
|
||||||
|
|
|
@ -11666,6 +11666,15 @@ re_scan:
|
||||||
if (opcode == WASM_OP_CALL_REF
|
if (opcode == WASM_OP_CALL_REF
|
||||||
|| opcode == WASM_OP_RETURN_CALL_REF) {
|
|| opcode == WASM_OP_RETURN_CALL_REF) {
|
||||||
read_leb_uint32(p, p_end, type_idx1);
|
read_leb_uint32(p, p_end, type_idx1);
|
||||||
|
if (!check_type_index(module, module->type_count, type_idx1,
|
||||||
|
error_buf, error_buf_size)) {
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
if (module->types[type_idx1]->type_flag != WASM_TYPE_FUNC) {
|
||||||
|
set_error_buf(error_buf, error_buf_size,
|
||||||
|
"unkown function type");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
if (!wasm_loader_pop_nullable_typeidx(loader_ctx, &type,
|
if (!wasm_loader_pop_nullable_typeidx(loader_ctx, &type,
|
||||||
&type_idx, error_buf,
|
&type_idx, error_buf,
|
||||||
error_buf_size)) {
|
error_buf_size)) {
|
||||||
|
@ -11683,7 +11692,9 @@ re_scan:
|
||||||
"unkown function type");
|
"unkown function type");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
if (type_idx != type_idx1) {
|
if (!wasm_func_type_is_super_of(
|
||||||
|
(WASMFuncType *)module->types[type_idx1],
|
||||||
|
(WASMFuncType *)module->types[type_idx])) {
|
||||||
set_error_buf(error_buf, error_buf_size,
|
set_error_buf(error_buf, error_buf_size,
|
||||||
"function type mismatch");
|
"function type mismatch");
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user