@@ -18,7 +18,7 @@ pub fn process_withdraw_excess_lamports(accounts: &[AccountInfo]) -> ProgramResu
18
18
return Err ( ProgramError :: NotEnoughAccountKeys ) ;
19
19
} ;
20
20
21
- // SAFETY: single mutable borrow to `source_account_info` account data
21
+ // SAFETY: single immutable borrow to `source_account_info` account data
22
22
let source_data = unsafe { source_account_info. borrow_data_unchecked ( ) } ;
23
23
24
24
match source_data. len ( ) {
@@ -36,10 +36,25 @@ pub fn process_withdraw_excess_lamports(accounts: &[AccountInfo]) -> ProgramResu
36
36
// SAFETY: `source_data` has the same length as `Mint`.
37
37
let mint = unsafe { load :: < Mint > ( source_data) ? } ;
38
38
39
- if let Some ( mint_authority) = mint. mint_authority ( ) {
40
- validate_owner ( mint_authority, authority_info, remaining) ?;
41
- } else {
42
- return Err ( TokenError :: AuthorityTypeNotSupported . into ( ) ) ;
39
+ match mint. mint_authority ( ) {
40
+ Some ( mint_authority) => {
41
+ validate_owner ( mint_authority, authority_info, remaining) ?;
42
+ }
43
+ None if source_account_info == authority_info => {
44
+ // Comparing whether the AccountInfo's "point" to the same account or
45
+ // not - this is a faster comparison since it just checks the internal
46
+ // raw pointer.
47
+ //
48
+ // This is a special case where there is no mint authority set but the mint
49
+ // account is the same as the authority account and, therefore, needs to be
50
+ // a signer.
51
+ if !authority_info. is_signer ( ) {
52
+ return Err ( ProgramError :: MissingRequiredSignature ) ;
53
+ }
54
+ }
55
+ _ => {
56
+ return Err ( TokenError :: AuthorityTypeNotSupported . into ( ) ) ;
57
+ }
43
58
}
44
59
}
45
60
Multisig :: LEN => {
0 commit comments