From fe9b30b81b83b470c5253fc58dce63bcc6b9b603 Mon Sep 17 00:00:00 2001 From: Taylor Whatley <32211852+1whatleytay@users.noreply.github.com> Date: Tue, 12 Nov 2024 13:40:07 -0500 Subject: [PATCH] Catch potential panic for random int range syscall --- src-backend/src/syscall.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src-backend/src/syscall.rs b/src-backend/src/syscall.rs index c753802..bf3dbab 100644 --- a/src-backend/src/syscall.rs +++ b/src-backend/src/syscall.rs @@ -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);