validate: check function argument type to be in range

This commit is contained in:
Dzmitry Malyshau
2022-01-13 14:35:34 -05:00
parent ee0cb0d5d3
commit fee69774a3

View File

@@ -837,7 +837,14 @@ impl super::Validator {
#[cfg(feature = "validate")]
for (index, argument) in fun.arguments.iter().enumerate() {
match module.types[argument.ty].inner.pointer_class() {
let ty = module.types.get_handle(argument.ty).ok_or(
FunctionError::InvalidArgumentType {
index,
name: argument.name.clone().unwrap_or_default(),
}
.with_span_handle(argument.ty, &module.types),
)?;
match ty.inner.pointer_class() {
Some(crate::StorageClass::Private)
| Some(crate::StorageClass::Function)
| Some(crate::StorageClass::WorkGroup)