فهرست منبع

Fix a ubsan complaint "applying zero offset to null pointer" (#3160)

Set a type's `result_ref_type_maps` only when `ref_type_map_count > 0`.
YAMAMOTO Takashi 1 سال پیش
والد
کامیت
b0c54c8a86
1فایلهای تغییر یافته به همراه4 افزوده شده و 2 حذف شده
  1. 4 2
      core/iwasm/interpreter/wasm_loader.c

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

@@ -1568,8 +1568,10 @@ resolve_func_type(const uint8 **p_buf, const uint8 *buf_end, WASMModule *module,
     type->param_count = param_count;
     type->result_count = result_count;
     type->ref_type_map_count = ref_type_map_count;
-    type->result_ref_type_maps =
-        type->ref_type_maps + ref_type_map_count - result_ref_type_map_count;
+    if (ref_type_map_count > 0) {
+        type->result_ref_type_maps = type->ref_type_maps + ref_type_map_count
+                                     - result_ref_type_map_count;
+    }
 
     for (i = 0; i < param_count; i++) {
         if (!resolve_value_type(&p, p_end, module, &need_ref_type_map,