Skip to content

Commit

Permalink
stake-pool: Add checked math to big vec calc (solana-labs#2524)
Browse files Browse the repository at this point in the history
  • Loading branch information
joncinque authored Oct 18, 2021
1 parent f97c61a commit 7f0278c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion stake-pool/program/src/big_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ impl<'data> BigVec<'data> {
len: usize,
) -> Result<Vec<&'data mut T>, ProgramError> {
let vec_len = self.len();
if skip + len > vec_len as usize {
let last_item_index = skip
.checked_add(len)
.ok_or(ProgramError::AccountDataTooSmall)?;
if last_item_index > vec_len as usize {
return Err(ProgramError::AccountDataTooSmall);
}

Expand Down

0 comments on commit 7f0278c

Please sign in to comment.