Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 7f0278c

Browse files
authored
stake-pool: Add checked math to big vec calc (#2524)
1 parent f97c61a commit 7f0278c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

stake-pool/program/src/big_vec.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ impl<'data> BigVec<'data> {
9090
len: usize,
9191
) -> Result<Vec<&'data mut T>, ProgramError> {
9292
let vec_len = self.len();
93-
if skip + len > vec_len as usize {
93+
let last_item_index = skip
94+
.checked_add(len)
95+
.ok_or(ProgramError::AccountDataTooSmall)?;
96+
if last_item_index > vec_len as usize {
9497
return Err(ProgramError::AccountDataTooSmall);
9598
}
9699

0 commit comments

Comments
 (0)