From fee69774a3c501d774e1f71263c2b44e087f2750 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Thu, 13 Jan 2022 14:35:34 -0500 Subject: [PATCH] validate: check function argument type to be in range --- src/valid/function.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/valid/function.rs b/src/valid/function.rs index 66f5965dbb..411ef7ce18 100644 --- a/src/valid/function.rs +++ b/src/valid/function.rs @@ -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)