validate: check global var type to be in range

This commit is contained in:
Dzmitry Malyshau
2022-01-13 14:27:39 -05:00
parent a4ea9ce68d
commit c9f52bd651

View File

@@ -332,7 +332,10 @@ impl super::Validator {
use super::TypeFlags;
log::debug!("var {:?}", var);
let type_info = &self.types[var.ty.index()];
let type_info = self
.types
.get(var.ty.index())
.ok_or(GlobalVariableError::InvalidType)?;
let (required_type_flags, is_resource) = match var.class {
crate::StorageClass::Function => return Err(GlobalVariableError::InvalidUsage),