Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions sdk/pinocchio/src/account_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,25 @@ impl AccountInfo {
// Check wheather the account data is already borrowed.
self.can_borrow_mut_data()?;

// SAFETY:
// We are checking if the account data is already borrowed, so we are safe to call
unsafe {
self.resize_unchecked(new_len)?;
}

Ok(())
}

/// Resizes the account's data and udpates the resize delta without checking if the account is already borrowed.
///
/// The account data can be increased by up to [`MAX_PERMITTED_DATA_INCREASE`] bytes
///
/// # Safety
///
/// This method is unsafe because it does not check if the account data is already
/// borrowed.
#[inline(always)]
pub unsafe fn resize_unchecked(&self, new_len: usize) -> Result<(), ProgramError> {
// Account length is always `< i32::MAX`...
let current_len = self.data_len() as i32;
// ...so the new length must fit in an `i32`.
Expand Down
Loading