Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion program-runtime/src/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,14 @@ fn deserialize_parameters_unaligned<I: IntoIterator<Item = usize>>(
.get(start..start + pre_len)
.ok_or(InstructionError::InvalidArgument)?;
// The redundant check helps to avoid the expensive data comparison if we can
match borrowed_account.can_data_be_resized(data.len()) {
match borrowed_account.can_data_be_resized(pre_len) {
Copy link
Copy Markdown
Author

@Lichtso Lichtso Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a non-functional change because data.len() == pre_len. Just for the sake of readability and consistency with the other three places here and in the aligned derserialization.

Ok(()) => borrowed_account.set_data_from_slice(data)?,
Err(err) if borrowed_account.get_data() != data => return Err(err),
_ => {}
}
start += pre_len; // data
} else if borrowed_account.get_data().len() != pre_len {
borrowed_account.set_data_length(pre_len)?;
}
start += size_of::<Pubkey>() // owner
+ size_of::<u8>() // executable
Expand Down
4 changes: 2 additions & 2 deletions programs/sbf/tests/programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3955,12 +3955,12 @@ fn test_cpi_account_data_updates() {
let account = bank.get_account(&account_keypair.pubkey()).unwrap();
// deprecated_callee is incapable of resizing accounts
assert_eq!(account.data(), b"foobar");
} else if deprecated_caller && (deprecated_callee || !direct_mapping) {
} else if deprecated_caller {
assert_eq!(
result.unwrap_err().unwrap(),
TransactionError::InstructionError(
0,
if direct_mapping {
if direct_mapping && deprecated_callee {
InstructionError::InvalidRealloc
} else {
InstructionError::AccountDataSizeChanged
Expand Down
Loading