Skip to content

Commit 1e327df

Browse files
authored
Fix panic in ExitToNear (#865)
## Description If `input` is empty a panic occurs. This PR sets `flag` to the default value in that case. ## Performance / NEAR gas cost considerations ## Testing Fuzzing. ## How should this be reviewed Ensure that `flag` assuming the default value if `input` is empty is the intended behavior. ## Additional information
1 parent 0d2acf0 commit 1e327df

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

engine-precompiles/src/native.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ impl<I: IO> Precompile for ExitToNear<I> {
349349
// First byte of the input is a flag, selecting the behavior to be triggered:
350350
// 0x0 -> Eth transfer
351351
// 0x1 -> Erc20 transfer
352-
let flag = input[0];
352+
let flag = input.first().copied().unwrap_or_default();
353353
#[cfg(feature = "error_refund")]
354354
let (refund_address, mut input) = parse_input(input)?;
355355
#[cfg(not(feature = "error_refund"))]

0 commit comments

Comments
 (0)