|
| 1 | +diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_loader.c b/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_loader.c |
| 2 | +index 2a06f42..87af852 100644 |
| 3 | +--- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_loader.c |
| 4 | ++++ b/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_loader.c |
| 5 | +@@ -219,7 +219,10 @@ type2str(uint8 type) |
| 6 | + static bool |
| 7 | + is_32bit_type(uint8 type) |
| 8 | + { |
| 9 | +- if (type == VALUE_TYPE_I32 || type == VALUE_TYPE_F32 |
| 10 | ++ if (type == VALUE_TYPE_I32 |
| 11 | ++ || type == VALUE_TYPE_F32 |
| 12 | ++ /* the operand stack is in polymorphic state */ |
| 13 | ++ || type == VALUE_TYPE_ANY |
| 14 | + #if WASM_ENABLE_REF_TYPES != 0 |
| 15 | + || type == VALUE_TYPE_FUNCREF || type == VALUE_TYPE_EXTERNREF |
| 16 | + #endif |
| 17 | +@@ -6690,6 +6693,7 @@ wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth, |
| 18 | + int32 i, available_stack_cell; |
| 19 | + uint16 cell_num; |
| 20 | + |
| 21 | ++ bh_assert(loader_ctx->csp_num > 0); |
| 22 | + if (loader_ctx->csp_num < depth + 1) { |
| 23 | + set_error_buf(error_buf, error_buf_size, |
| 24 | + "unknown label, " |
| 25 | +@@ -7758,8 +7762,7 @@ re_scan: |
| 26 | + } |
| 27 | + |
| 28 | + if (available_stack_cell > 0) { |
| 29 | +- if (is_32bit_type(*(loader_ctx->frame_ref - 1)) |
| 30 | +- || *(loader_ctx->frame_ref - 1) == VALUE_TYPE_ANY) { |
| 31 | ++ if (is_32bit_type(*(loader_ctx->frame_ref - 1))) { |
| 32 | + loader_ctx->frame_ref--; |
| 33 | + loader_ctx->stack_cell_num--; |
| 34 | + #if WASM_ENABLE_FAST_INTERP != 0 |
| 35 | +diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_mini_loader.c b/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_mini_loader.c |
| 36 | +index 47ec549..157a82c 100644 |
| 37 | +--- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_mini_loader.c |
| 38 | ++++ b/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_mini_loader.c |
| 39 | +@@ -51,7 +51,10 @@ set_error_buf(char *error_buf, uint32 error_buf_size, const char *string) |
| 40 | + static bool |
| 41 | + is_32bit_type(uint8 type) |
| 42 | + { |
| 43 | +- if (type == VALUE_TYPE_I32 || type == VALUE_TYPE_F32 |
| 44 | ++ if (type == VALUE_TYPE_I32 |
| 45 | ++ || type == VALUE_TYPE_F32 |
| 46 | ++ /* the operand stack is in polymorphic state */ |
| 47 | ++ || type == VALUE_TYPE_ANY |
| 48 | + #if WASM_ENABLE_REF_TYPES != 0 |
| 49 | + || type == VALUE_TYPE_FUNCREF || type == VALUE_TYPE_EXTERNREF |
| 50 | + #endif |
| 51 | +@@ -3930,7 +3933,7 @@ wasm_loader_pop_frame_ref(WASMLoaderContext *ctx, uint8 type, char *error_buf, |
| 52 | + ctx->frame_ref--; |
| 53 | + ctx->stack_cell_num--; |
| 54 | + |
| 55 | +- if (is_32bit_type(type) || *ctx->frame_ref == VALUE_TYPE_ANY) |
| 56 | ++ if (is_32bit_type(type)) |
| 57 | + return true; |
| 58 | + |
| 59 | + ctx->frame_ref--; |
| 60 | +@@ -5839,13 +5842,11 @@ re_scan: |
| 61 | + case WASM_OP_BR_TABLE: |
| 62 | + { |
| 63 | + uint8 *ret_types = NULL; |
| 64 | +- uint32 ret_count = 0; |
| 65 | ++ uint32 ret_count = 0, depth = 0; |
| 66 | + #if WASM_ENABLE_FAST_INTERP == 0 |
| 67 | +- uint8 *p_depth_begin, *p_depth; |
| 68 | +- uint32 depth, j; |
| 69 | + BrTableCache *br_table_cache = NULL; |
| 70 | +- |
| 71 | +- p_org = p - 1; |
| 72 | ++ uint8 *p_depth_begin, *p_depth, *p_opcode = p - 1; |
| 73 | ++ uint32 j; |
| 74 | + #endif |
| 75 | + |
| 76 | + read_leb_uint32(p, p_end, count); |
| 77 | +@@ -5854,6 +5855,16 @@ re_scan: |
| 78 | + #endif |
| 79 | + POP_I32(); |
| 80 | + |
| 81 | ++ /* Get each depth and check it */ |
| 82 | ++ p_org = p; |
| 83 | ++ for (i = 0; i <= count; i++) { |
| 84 | ++ read_leb_uint32(p, p_end, depth); |
| 85 | ++ bh_assert(loader_ctx->csp_num > 0); |
| 86 | ++ bh_assert(loader_ctx->csp_num - 1 >= depth); |
| 87 | ++ (void)depth; |
| 88 | ++ } |
| 89 | ++ p = p_org; |
| 90 | ++ |
| 91 | + #if WASM_ENABLE_FAST_INTERP == 0 |
| 92 | + p_depth_begin = p_depth = p; |
| 93 | + #endif |
| 94 | +@@ -5879,8 +5890,8 @@ re_scan: |
| 95 | + error_buf, error_buf_size))) { |
| 96 | + goto fail; |
| 97 | + } |
| 98 | +- *p_org = EXT_OP_BR_TABLE_CACHE; |
| 99 | +- br_table_cache->br_table_op_addr = p_org; |
| 100 | ++ *p_opcode = EXT_OP_BR_TABLE_CACHE; |
| 101 | ++ br_table_cache->br_table_op_addr = p_opcode; |
| 102 | + br_table_cache->br_count = count; |
| 103 | + /* Copy previous depths which are one byte */ |
| 104 | + for (j = 0; j < i; j++) { |
| 105 | +@@ -6099,8 +6110,7 @@ re_scan: |
| 106 | + && !cur_block->is_stack_polymorphic)); |
| 107 | + |
| 108 | + if (available_stack_cell > 0) { |
| 109 | +- if (is_32bit_type(*(loader_ctx->frame_ref - 1)) |
| 110 | +- || *(loader_ctx->frame_ref - 1) == VALUE_TYPE_ANY) { |
| 111 | ++ if (is_32bit_type(*(loader_ctx->frame_ref - 1))) { |
| 112 | + loader_ctx->frame_ref--; |
| 113 | + loader_ctx->stack_cell_num--; |
| 114 | + #if WASM_ENABLE_FAST_INTERP != 0 |
0 commit comments