Skip to content

Commit ff21631

Browse files
committed
fix: use try_into instead of as u64 cast in push_buffer
Signed-off-by: JM00NJ <51642194+JM00NJ@users.noreply.github.com>
1 parent 570cf7d commit ff21631

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/hyperlight_host/src/mem/shared_mem.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,10 +1399,12 @@ impl HostSharedMemory {
13991399
self.write::<u64>(stack_pointer_abs + data.len(), stack_pointer_rel as u64)?;
14001400

14011401
// update stack pointer to point to the next free address
1402-
let new_sp = stack_pointer_rel
1402+
let new_sp: u64 = stack_pointer_rel
14031403
.checked_add(data.len())
14041404
.and_then(|v| v.checked_add(8))
1405-
.ok_or(StackError::PushSizeOverflow(data.len()))? as u64;
1405+
.ok_or(StackError::PushSizeOverflow(data.len()))?
1406+
.try_into()
1407+
.map_err(|_| StackError::PushSizeOverflow(data.len()))?;
14061408
self.write::<u64>(buffer_start_offset, new_sp)?;
14071409
Ok(())
14081410
}

0 commit comments

Comments
 (0)