Skip to content

Commit

Permalink
Fix panic in ExitToNear (#865)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
guidovranken authored Nov 14, 2023
1 parent 0d2acf0 commit 1e327df
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion engine-precompiles/src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ impl<I: IO> Precompile for ExitToNear<I> {
// First byte of the input is a flag, selecting the behavior to be triggered:
// 0x0 -> Eth transfer
// 0x1 -> Erc20 transfer
let flag = input[0];
let flag = input.first().copied().unwrap_or_default();
#[cfg(feature = "error_refund")]
let (refund_address, mut input) = parse_input(input)?;
#[cfg(not(feature = "error_refund"))]
Expand Down

0 comments on commit 1e327df

Please sign in to comment.