From 5e613af62b466cb8a9a235a4ea64ace2e003aaa8 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 18 May 2022 14:22:16 -0700 Subject: Validator: Check features for ref.null's type (#4677) --- src/wasm/wasm-validator.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/wasm/wasm-validator.cpp') diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 39eb996ea..c74d95fdd 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -1999,6 +1999,11 @@ void FunctionValidator::visitRefNull(RefNull* curr) { "ref.null requires reference-types to be enabled"); shouldBeTrue( curr->type.isNullable(), curr, "ref.null types must be nullable"); + + // The type of the null must also be valid for the features. + shouldBeTrue(curr->type.getFeatures() <= getModule()->features, + curr->type, + "ref.null type should be allowed"); } void FunctionValidator::visitRefIs(RefIs* curr) { -- cgit v1.2.3