Skip to content

Commit 3b92f39

Browse files
committed
Review comments
1 parent aaa602c commit 3b92f39

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

p-token/src/processor/unwrap_lamports.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use {
22
super::validate_owner,
3-
crate::processor::{check_account_owner, U64_BYTES},
3+
crate::processor::{check_account_owner, unpack_amount},
44
pinocchio::{account_info::AccountInfo, program_error::ProgramError, ProgramResult},
55
pinocchio_token_interface::{
66
error::TokenError,
@@ -18,11 +18,8 @@ pub fn process_unwrap_lamports(accounts: &[AccountInfo], instruction_data: &[u8]
1818

1919
let maybe_amount = if likely(*has_amount == 0) {
2020
None
21-
} else if maybe_amount.len() >= 8 {
22-
// SAFETY: The slice is guaranteed to be at least 8 bytes long.
23-
Some(u64::from_le_bytes(unsafe {
24-
*(maybe_amount.as_ptr() as *const [u8; U64_BYTES])
25-
}))
21+
} else if *has_amount == 1 {
22+
Some(unpack_amount(maybe_amount)?)
2623
} else {
2724
return Err(TokenError::InvalidInstruction.into());
2825
};

0 commit comments

Comments
 (0)