@@ -854,20 +854,17 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
854854 true, heap_type);
855855 type1 = cur_ref_type.ref_type;
856856
857- if (!is_byte_a_type(type1)
858- || wasm_is_type_multi_byte_type(type1)) {
859- if (!push_const_expr_stack(&const_expr_ctx, flag,
860- cur_ref_type.ref_type,
861- &cur_ref_type, 0, &cur_value,
862- error_buf, error_buf_size))
863- goto fail;
864- }
865- else {
866- if (!push_const_expr_stack(&const_expr_ctx, flag, type1,
867- NULL, 0, &cur_value,
868- error_buf, error_buf_size))
869- goto fail;
870- }
857+ /*
858+ * Since wasm_set_refheaptype_typeidx(...) always sets type1
859+ * to REF_TYPE_HT_NULLABLE, the condition (!is_byte_a_type
860+ * || wasm_is_type_multi_byte_byte()) is always true. Thus,
861+ * this validation is no longer necessary and has been
862+ * removed.
863+ */
864+ if (!push_const_expr_stack(&const_expr_ctx, flag, type1,
865+ &cur_ref_type, 0, &cur_value,
866+ error_buf, error_buf_size))
867+ goto fail;
871868 }
872869 else {
873870 if (!wasm_is_valid_heap_type(heap_type)) {
@@ -876,13 +873,13 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
876873 goto fail;
877874 }
878875 /*
879- * When heap_type < 0 and wasm_is_valid_heap_type(heap_type)
880- * is true, under the current implementation, the condition
876+ * When heap_type < 0, there is no need to call
877+ * check_type_index, and the condition
881878 * (!is_byte_a_type(type1) ||
882- * wasm_is_type_multi_byte_type(type1)) will always be
883- * false, so there is no need to check_type_index here. If
884- * the implementation changes in the future, this check may
885- * be needed.
879+ * wasm_is_type_multi_byte_type(type1)) is always false.
880+ * Therefore, for both reasons, check_type_index is
881+ * unnecessary here. If the implementation changes in the
882+ * future, this check may be needed.
886883 */
887884 type1 = (uint8)((int32)0x80 + heap_type);
888885
0 commit comments