Skip to content

Commit

Permalink
Fix sol_get_processed_sibling_instruction on 32-bit hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
riptl committed Jul 27, 2022
1 parent 1421833 commit c41462e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions programs/bpf_loader/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1750,8 +1750,9 @@ declare_syscall!(
result
);

if *data_len == instruction_context.get_instruction_data().len()
&& *accounts_len == instruction_context.get_number_of_instruction_accounts()
if *data_len == (instruction_context.get_instruction_data().len() as u64)
&& *accounts_len
== (instruction_context.get_number_of_instruction_accounts() as u64)
{
let program_id = question_mark!(
translate_type_mut::<Pubkey>(
Expand Down Expand Up @@ -1809,8 +1810,8 @@ declare_syscall!(
);
accounts.clone_from_slice(account_metas.as_slice());
}
*data_len = instruction_context.get_instruction_data().len();
*accounts_len = instruction_context.get_number_of_instruction_accounts();
*data_len = instruction_context.get_instruction_data().len() as u64;
*accounts_len = instruction_context.get_number_of_instruction_accounts() as u64;
*result = Ok(true as u64);
return;
}
Expand Down
8 changes: 4 additions & 4 deletions sdk/program/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,9 +664,9 @@ impl CompiledInstruction {
#[derive(Default, Debug, Clone, Copy)]
pub struct ProcessedSiblingInstruction {
/// Length of the instruction data
pub data_len: usize,
pub data_len: u64,
/// Number of AccountMeta structures
pub accounts_len: usize,
pub accounts_len: u64,
}

/// Returns a sibling instruction from the processed sibling instruction list.
Expand Down Expand Up @@ -698,8 +698,8 @@ pub fn get_processed_sibling_instruction(index: usize) -> Option<Instruction> {
} {
let mut data = Vec::new();
let mut accounts = Vec::new();
data.resize_with(meta.data_len, u8::default);
accounts.resize_with(meta.accounts_len, AccountMeta::default);
data.resize_with(meta.data_len as usize, u8::default);
accounts.resize_with(meta.accounts_len as usize, AccountMeta::default);

let _ = unsafe {
crate::syscalls::sol_get_processed_sibling_instruction(
Expand Down

0 comments on commit c41462e

Please sign in to comment.