mirror of
https://github.com/fluencelabs/interface-types
synced 2024-12-04 15:20:20 +00:00
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.
This commit is contained in:
parent
63f824a240
commit
b63ce1be6c
@ -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 },
|
||||
|
Loading…
Reference in New Issue
Block a user