File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -495,6 +495,25 @@ impl AccountInfo {
495495 // Check wheather the account data is already borrowed.
496496 self . can_borrow_mut_data ( ) ?;
497497
498+ // SAFETY:
499+ // We are checking if the account data is already borrowed, so we are safe to call
500+ unsafe {
501+ self . resize_unchecked ( new_len) ?;
502+ }
503+
504+ Ok ( ( ) )
505+ }
506+
507+ /// Resizes the account's data and udpates the resize delta without checking if the account is already borrowed.
508+ ///
509+ /// The account data can be increased by up to [`MAX_PERMITTED_DATA_INCREASE`] bytes
510+ ///
511+ /// # Safety
512+ ///
513+ /// This method is unsafe because it does not check if the account data is already
514+ /// borrowed.
515+ #[ inline( always) ]
516+ pub unsafe fn resize_unchecked ( & self , new_len : usize ) -> Result < ( ) , ProgramError > {
498517 // Account length is always `< i32::MAX`...
499518 let current_len = self . data_len ( ) as i32 ;
500519 // ...so the new length must fit in an `i32`.
You can’t perform that action at this time.
0 commit comments