Skip to content

Commit

Permalink
Catch potential panic for random int range syscall
Browse files Browse the repository at this point in the history
  • Loading branch information
1whatleytay committed Nov 12, 2024
1 parent 8dccceb commit fe9b30b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src-backend/src/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,10 @@ impl SyscallDelegate {
let Some(generator) = syscall.generators.get_mut(&id) else {
return Self::fail_generator(id)
};

if max <= 0 {
return Failure("Empty range for random int, please set $a0 to a value greater than 0.".to_string())
}

let value: u32 = generator.gen_range(0..max);

Expand Down

0 comments on commit fe9b30b

Please sign in to comment.