Просмотр исходного кода

Remove PRI macro control in wasm_application.c (#905)

And fix read_leb byte count check issue in aot_compiler.c
Wenyong Huang 4 лет назад
Родитель
Сommit
af251e45ca
2 измененных файлов с 3 добавлено и 20 удалено
  1. 0 18
      core/iwasm/common/wasm_application.c
  2. 3 2
      core/iwasm/compilation/aot_compiler.c

+ 0 - 18
core/iwasm/common/wasm_application.c

@@ -586,16 +586,7 @@ wasm_application_execute_func(WASMModuleInstanceCommon *module_inst,
                 u.parts[0] = argv1[k];
                 u.parts[1] = argv1[k + 1];
                 k += 2;
-#ifdef PRIx64
                 os_printf("0x%" PRIx64 ":i64", u.val);
-#else
-                char buf[16];
-                if (sizeof(long) == 4)
-                    snprintf(buf, sizeof(buf), "%s", "0x%llx:i64");
-                else
-                    snprintf(buf, sizeof(buf), "%s", "0x%lx:i64");
-                os_printf(buf, u.val);
-#endif
                 break;
             }
             case VALUE_TYPE_F32:
@@ -645,17 +636,8 @@ wasm_application_execute_func(WASMModuleInstanceCommon *module_inst,
             case VALUE_TYPE_V128:
             {
                 uint64 *v = (uint64 *)(argv1 + k);
-#if defined(PRIx64)
                 os_printf("<0x%016" PRIx64 " 0x%016" PRIx64 ">:v128", *v,
                           *(v + 1));
-#else
-                if (4 == sizeof(long)) {
-                    os_printf("<0x%016llx 0x%016llx>:v128", *v, *(v + 1));
-                }
-                else {
-                    os_printf("<0x%016lx 0x%016lx>:v128", *v, *(v + 1));
-                }
-#endif /* PRIx64 */
                 k += 4;
                 break;
             }

+ 3 - 2
core/iwasm/compilation/aot_compiler.c

@@ -64,8 +64,9 @@ read_leb(const uint8 *buf, const uint8 *buf_end, uint32 *p_offset,
         }
         bcnt += 1;
     }
-    if (bcnt > (((maxbits + 8) >> 3) - (maxbits + 8))) {
-        aot_set_last_error("read leb failed: unsigned leb overflow.");
+    if (bcnt > (maxbits + 6) / 7) {
+        aot_set_last_error("read leb failed: "
+                           "integer representation too long");
         return false;
     }
     if (sign && (shift < maxbits) && (byte & 0x40)) {