(
&mut self,
function_def_idx: usize,
function_def: &FunctionDefinition,
)
| 306 | } |
| 307 | |
| 308 | fn check_function_def( |
| 309 | &mut self, |
| 310 | function_def_idx: usize, |
| 311 | function_def: &FunctionDefinition, |
| 312 | ) -> PartialVMResult<()> { |
| 313 | self.context = BoundsCheckingContext::ModuleFunction(FunctionDefinitionIndex( |
| 314 | function_def_idx as TableIndex, |
| 315 | )); |
| 316 | check_bounds_impl(self.view.function_handles(), function_def.function)?; |
| 317 | for ty in &function_def.acquires_global_resources { |
| 318 | check_bounds_impl_opt(&self.view.struct_defs(), *ty)?; |
| 319 | } |
| 320 | |
| 321 | let code_unit = match &function_def.code { |
| 322 | Some(code) => code, |
| 323 | None => return Ok(()), |
| 324 | }; |
| 325 | |
| 326 | debug_assert!(function_def.function.into_index() < self.view.function_handles().len()); |
| 327 | let function_handle = &self.view.function_handles()[function_def.function.into_index()]; |
| 328 | |
| 329 | debug_assert!(function_handle.parameters.into_index() < self.view.signatures().len()); |
| 330 | let parameters = &self.view.signatures()[function_handle.parameters.into_index()]; |
| 331 | |
| 332 | // check if the number of parameters + locals is less than u8::MAX |
| 333 | let locals_count = self.get_locals(code_unit)?.len() + parameters.len(); |
| 334 | |
| 335 | if locals_count > (u8::MAX as usize) + 1 { |
| 336 | return Err(verification_error( |
| 337 | StatusCode::TOO_MANY_LOCALS, |
| 338 | IndexKind::FunctionDefinition, |
| 339 | function_def_idx as TableIndex, |
| 340 | )); |
| 341 | } |
| 342 | |
| 343 | self.check_code(code_unit, &function_handle.type_parameters, parameters) |
| 344 | } |
| 345 | |
| 346 | fn check_code( |
| 347 | &self, |
no test coverage detected