Skip to content

Commit e091f29

Browse files
authored
Gate types coming through ref.null (#1310)
This fixes a regression from #1299 where `ref.null array`, a wasm GC instruction, wasn't being properly gated by the `gc` feature.
1 parent f13f42f commit e091f29

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

crates/wasmparser/src/validator/operators.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,6 +2243,11 @@ where
22432243
Ok(())
22442244
}
22452245
fn visit_ref_null(&mut self, mut heap_type: HeapType) -> Self::Output {
2246+
if let Some(ty) = RefType::new(true, heap_type) {
2247+
self.features
2248+
.check_ref_type(ty)
2249+
.map_err(|e| BinaryReaderError::new(e, self.offset))?;
2250+
}
22462251
self.resources
22472252
.check_heap_type(&mut heap_type, self.offset)?;
22482253
let ty = ValType::Ref(

tests/local/missing-features/reference-types/gc.wast

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@
2828
(assert_invalid
2929
(module (func (block (result i31ref) unreachable)))
3030
"heap types not supported without the gc feature")
31+
(assert_invalid
32+
(module (func ref.null array drop))
33+
"heap types not supported without the gc feature")

0 commit comments

Comments
 (0)