Skip to content

Commit c2d51de

Browse files
committed
add heaptype check for GC when ref.null
1 parent 782c69f commit c2d51de

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

core/iwasm/interpreter/wasm_loader.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,19 +808,24 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
808808
{
809809
uint8 type1;
810810

811+
#if WASM_ENABLE_GC == 0
811812
CHECK_BUF(p, p_end, 1);
812813
type1 = read_uint8(p);
813814

814-
#if WASM_ENABLE_GC == 0
815815
cur_value.ref_index = NULL_REF;
816816
if (!push_const_expr_stack(&const_expr_ctx, flag, type1,
817817
&cur_value, error_buf,
818818
error_buf_size))
819819
goto fail;
820820
#else
821+
int32 heap_type;
822+
read_leb_int32(p, p_end, heap_type);
823+
type1 = (uint8)((int32)0x80 + heap_type);
824+
821825
cur_value.gc_obj = NULL_REF;
822826

823827
if (!is_byte_a_type(type1)
828+
|| !wasm_is_valid_heap_type(heap_type)
824829
|| wasm_is_type_multi_byte_type(type1)) {
825830
p--;
826831
read_leb_uint32(p, p_end, type_idx);

0 commit comments

Comments
 (0)