فهرست منبع

Fix opcode overwrite issue in fast interp (#2476)

Xu Jun 2 سال پیش
والد
کامیت
7baaed2fb8
2فایلهای تغییر یافته به همراه6 افزوده شده و 4 حذف شده
  1. 3 2
      core/iwasm/interpreter/wasm_loader.c
  2. 3 2
      core/iwasm/interpreter/wasm_mini_loader.c

+ 3 - 2
core/iwasm/interpreter/wasm_loader.c

@@ -8064,6 +8064,9 @@ re_scan:
             case WASM_OP_SELECT_T:
             case WASM_OP_SELECT_T:
             {
             {
                 uint8 vec_len, ref_type;
                 uint8 vec_len, ref_type;
+#if WASM_ENABLE_FAST_INTERP != 0
+                uint8 *p_code_compiled_tmp = loader_ctx->p_code_compiled;
+#endif
 
 
                 read_leb_uint32(p, p_end, vec_len);
                 read_leb_uint32(p, p_end, vec_len);
                 if (vec_len != 1) {
                 if (vec_len != 1) {
@@ -8086,8 +8089,6 @@ re_scan:
 #if WASM_ENABLE_FAST_INTERP != 0
 #if WASM_ENABLE_FAST_INTERP != 0
                 if (loader_ctx->p_code_compiled) {
                 if (loader_ctx->p_code_compiled) {
                     uint8 opcode_tmp = WASM_OP_SELECT;
                     uint8 opcode_tmp = WASM_OP_SELECT;
-                    uint8 *p_code_compiled_tmp =
-                        loader_ctx->p_code_compiled - 2;
 
 
                     if (ref_type == VALUE_TYPE_V128) {
                     if (ref_type == VALUE_TYPE_V128) {
 #if (WASM_ENABLE_SIMD == 0) \
 #if (WASM_ENABLE_SIMD == 0) \

+ 3 - 2
core/iwasm/interpreter/wasm_mini_loader.c

@@ -6233,6 +6233,9 @@ re_scan:
             case WASM_OP_SELECT_T:
             case WASM_OP_SELECT_T:
             {
             {
                 uint8 vec_len, ref_type;
                 uint8 vec_len, ref_type;
+#if WASM_ENABLE_FAST_INTERP != 0
+                uint8 *p_code_compiled_tmp = loader_ctx->p_code_compiled;
+#endif
 
 
                 read_leb_uint32(p, p_end, vec_len);
                 read_leb_uint32(p, p_end, vec_len);
                 if (vec_len != 1) {
                 if (vec_len != 1) {
@@ -6255,8 +6258,6 @@ re_scan:
 #if WASM_ENABLE_FAST_INTERP != 0
 #if WASM_ENABLE_FAST_INTERP != 0
                 if (loader_ctx->p_code_compiled) {
                 if (loader_ctx->p_code_compiled) {
                     uint8 opcode_tmp = WASM_OP_SELECT;
                     uint8 opcode_tmp = WASM_OP_SELECT;
-                    uint8 *p_code_compiled_tmp =
-                        loader_ctx->p_code_compiled - 2;
 
 
                     if (ref_type == VALUE_TYPE_F64
                     if (ref_type == VALUE_TYPE_F64
                         || ref_type == VALUE_TYPE_I64)
                         || ref_type == VALUE_TYPE_I64)