From b63ce1be6cb90135fd01c41b802a88cf778208c3 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Thu, 26 Mar 2020 07:46:59 +0100 Subject: [PATCH] fix(interface-types) Cast index to `usize` to compare index to length. The index is bound to `u32::max_value()`. The invocation inputs' length is bound to `usize::max_value()`, which can be `u64::max_value`. Consequently, casting the invocation inputs' length to `u32` can lead to an integer overflow. It is better to cast `index` to `usize` when comparing with the invocation inputs' length. --- src/interpreter/instructions/argument_get.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/interpreter/instructions/argument_get.rs b/src/interpreter/instructions/argument_get.rs index dd161e1..3b95405 100644 --- a/src/interpreter/instructions/argument_get.rs +++ b/src/interpreter/instructions/argument_get.rs @@ -8,7 +8,7 @@ executable_instruction!( move |runtime| -> _ { let invocation_inputs = runtime.invocation_inputs; - if index >= (invocation_inputs.len() as u32) { + if (index as usize) >= invocation_inputs.len() { return Err(InstructionError::new( instruction, InstructionErrorKind::InvocationInputIsMissing { index },