Skip to content

Commit 460e125

Browse files
committed
Load checks length
1 parent ed6c7d8 commit 460e125

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

program/rust/src/rust_oracle.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,11 @@ pub fn clear_account(account: &AccountInfo) -> Result<(), ProgramError> {
224224

225225
/// Interpret the bytes in `data` as a value of type `T`
226226
fn load<T: Pod>(data: &[u8]) -> Result<&T, ProgramError> {
227-
try_from_bytes(&data[0..size_of::<T>()]).map_err(|_| ProgramError::InvalidArgument)
227+
try_from_bytes(
228+
data.get(0..size_of::<T>())
229+
.ok_or(ProgramError::InvalidArgument)?,
230+
)
231+
.map_err(|_| ProgramError::InvalidArgument)
228232
}
229233

230234
/// Interpret the bytes in `data` as a mutable value of type `T`

0 commit comments

Comments
 (0)