Skip to content

Commit e16dd79

Browse files
committed
Improve remaining check
1 parent f04d723 commit e16dd79

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

pinocchio/program/src/processor/sync_native.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@ pub fn process_sync_native(accounts: &[AccountInfo]) -> ProgramResult {
2020

2121
check_account_owner(native_account_info)?;
2222

23-
let rent_exempt_reserve = if remaining.is_empty() {
24-
Rent::get()?.minimum_balance(native_account_info.data_len())
25-
} else {
26-
// SAFETY: `remaining` is guaranteed to not be empty.
27-
let rent_sysvar_info = unsafe { remaining.get_unchecked(0) };
23+
let rent_exempt_reserve = if let Some(rent_sysvar_info) = remaining.first() {
2824
// SAFETY: single immutable borrow to `rent_sysvar_info`; account ID and length
2925
// are checked by `from_account_info_unchecked`.
3026
let rent = unsafe { Rent::from_account_info_unchecked(rent_sysvar_info)? };
3127
rent.minimum_balance(native_account_info.data_len())
28+
} else {
29+
Rent::get()?.minimum_balance(native_account_info.data_len())
3230
};
3331

3432
// SAFETY: single mutable borrow to `native_account_info` account data and

0 commit comments

Comments
 (0)