Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 643eb65

Browse files
authored
[token-2022] improve condition in Account::valid_account_data (#6199)
* [token-2022] improve condition in Account::valid_account_data * use index directly
1 parent 0351963 commit 643eb65

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

token/program-2022/src/state.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,9 @@ impl GenericTokenAccount for Account {
303303
fn valid_account_data(account_data: &[u8]) -> bool {
304304
// Use spl_token::state::Account::valid_account_data once possible
305305
account_data.len() == Account::LEN && is_initialized_account(account_data)
306-
|| (account_data.len() >= Account::LEN
306+
|| (account_data.len() > Account::LEN
307307
&& account_data.len() != Multisig::LEN
308-
&& ACCOUNTTYPE_ACCOUNT
309-
== *account_data
310-
.get(spl_token::state::Account::get_packed_len())
311-
.unwrap_or(&(AccountType::Uninitialized as u8))
308+
&& ACCOUNTTYPE_ACCOUNT == account_data[Account::LEN]
312309
&& is_initialized_account(account_data))
313310
}
314311
}

0 commit comments

Comments
 (0)