File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ use solana_program::{
6
6
program_error:: ProgramError ,
7
7
pubkey:: Pubkey ,
8
8
rent:: Rent ,
9
- system_instruction,
9
+ system_instruction, system_program ,
10
10
sysvar:: Sysvar ,
11
11
} ;
12
12
@@ -108,13 +108,20 @@ pub fn close_account_raw<'a>(
108
108
src_account_info : & AccountInfo < ' a > ,
109
109
) -> ProgramResult {
110
110
let dest_starting_lamports = dest_account_info. lamports ( ) ;
111
- * * dest_account_info. lamports . borrow_mut ( ) = dest_starting_lamports
111
+ let mut dest_lamports_mut = dest_account_info
112
+ . lamports
113
+ . try_borrow_mut ( )
114
+ . map_err ( |_| ProgramError :: AccountBorrowFailed ) ?;
115
+ * * dest_lamports_mut = dest_starting_lamports
112
116
. checked_add ( src_account_info. lamports ( ) )
113
- . unwrap ( ) ;
114
- * * src_account_info. lamports . borrow_mut ( ) = 0 ;
117
+ . ok_or ( ProgramError :: InvalidRealloc ) ?;
115
118
116
- let mut src_data = src_account_info. data . borrow_mut ( ) ;
117
- src_data. fill ( 0 ) ;
119
+ let mut src_lamports_mut = src_account_info
120
+ . lamports
121
+ . try_borrow_mut ( )
122
+ . map_err ( |_| ProgramError :: AccountBorrowFailed ) ?;
123
+ * * src_lamports_mut = 0 ;
118
124
119
- Ok ( ( ) )
125
+ src_account_info. assign ( & system_program:: ID ) ;
126
+ src_account_info. realloc ( 0 , false ) . map_err ( Into :: into)
120
127
}
You can’t perform that action at this time.
0 commit comments