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

Fix AOT loader for struct type (#2658)

Add ref type into ref type set when loading struct type's ref type maps.
Huang Qi 2 лет назад
Родитель
Сommit
33627387ce
1 измененных файлов с 10 добавлено и 9 удалено
  1. 10 9
      core/iwasm/aot/aot_loader.c

+ 10 - 9
core/iwasm/aot/aot_loader.c

@@ -1421,15 +1421,16 @@ load_types(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
                 for (j = 0; j < struct_type->ref_type_map_count; j++) {
                     read_uint16(buf, buf_end,
                                 struct_type->ref_type_maps[j].index);
-                    read_uint8(buf, buf_end,
-                               struct_type->ref_type_maps[j]
-                                   .ref_type->ref_ht_common.ref_type);
-                    read_uint8(buf, buf_end,
-                               struct_type->ref_type_maps[j]
-                                   .ref_type->ref_ht_common.nullable);
-                    read_uint32(buf, buf_end,
-                                struct_type->ref_type_maps[j]
-                                    .ref_type->ref_ht_common.heap_type);
+                    read_uint8(buf, buf_end, ref_type.ref_ht_common.ref_type);
+                    read_uint8(buf, buf_end, ref_type.ref_ht_common.nullable);
+                    read_uint32(buf, buf_end, ref_type.ref_ht_common.heap_type);
+                    if (!(struct_type->ref_type_maps[j].ref_type =
+                              wasm_reftype_set_insert(module->ref_type_set,
+                                                      &ref_type))) {
+                        set_error_buf(error_buf, error_buf_size,
+                                      "insert ref type to hash set failed");
+                        goto fail;
+                    }
                 }
             }
         }