Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions p-token/src/processor/shared/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,17 @@ pub fn process_transfer(
if source_account.is_native() {
// SAFETY: single mutable borrow to `source_account_info` lamports.
let source_lamports = unsafe { source_account_info.borrow_mut_lamports_unchecked() };
*source_lamports = source_lamports
.checked_sub(amount)
.ok_or(TokenError::Overflow)?;
// Note: The amount of a source token account is already validated and the
// `lamports` on the account is always greater than `amount`.
*source_lamports -= amount;

// SAFETY: single mutable borrow to `destination_account_info` lamports; the
// account is already validated to be different from
// `source_account_info`.
let destination_lamports =
unsafe { destination_account_info.borrow_mut_lamports_unchecked() };
*destination_lamports = destination_lamports
.checked_add(amount)
.ok_or(TokenError::Overflow)?;
// Note: The total lamports supply is bound to `u64::MAX`.
*destination_lamports += amount;
}
}

Expand Down