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

Commit 8d79d85

Browse files
authored
token-2022: Add unnecessary owner checks for more clarity (#3759)
1 parent 12c11f6 commit 8d79d85

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

token/program-2022/src/extension/confidential_transfer/processor.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,8 @@ fn process_withdraw_withheld_tokens_from_mint(
874874
let authority_info = next_account_info(account_info_iter)?;
875875
let authority_info_data_len = authority_info.data_len();
876876

877+
// unnecessary check, but helps for clarity
878+
check_program_account(mint_account_info.owner)?;
877879
let mut mint_data = mint_account_info.data.borrow_mut();
878880
let mut mint = StateWithExtensionsMut::<Mint>::unpack(&mut mint_data)?;
879881

@@ -969,6 +971,8 @@ fn process_withdraw_withheld_tokens_from_accounts(
969971
.len()
970972
.saturating_sub(num_token_accounts as usize);
971973

974+
// unnecessary check, but helps for clarity
975+
check_program_account(mint_account_info.owner)?;
972976
let mut mint_data = mint_account_info.data.borrow_mut();
973977
let mut mint = StateWithExtensionsMut::<Mint>::unpack(&mut mint_data)?;
974978

token/program-2022/src/extension/transfer_fee/processor.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ fn process_withdraw_withheld_tokens_from_mint(
119119
let authority_info = next_account_info(account_info_iter)?;
120120
let authority_info_data_len = authority_info.data_len();
121121

122+
// unnecessary check, but helps for clarity
123+
check_program_account(mint_account_info.owner)?;
124+
122125
let mut mint_data = mint_account_info.data.borrow_mut();
123126
let mut mint = StateWithExtensionsMut::<Mint>::unpack(&mut mint_data)?;
124127
let extension = mint.get_extension_mut::<TransferFeeConfig>()?;
@@ -214,6 +217,9 @@ fn process_withdraw_withheld_tokens_from_accounts(
214217
.len()
215218
.saturating_sub(num_token_accounts as usize);
216219

220+
// unnecessary check, but helps for clarity
221+
check_program_account(mint_account_info.owner)?;
222+
217223
let mint_data = mint_account_info.data.borrow();
218224
let mint = StateWithExtensions::<Mint>::unpack(&mint_data)?;
219225
let extension = mint.get_extension::<TransferFeeConfig>()?;

0 commit comments

Comments
 (0)