From 0902e29f493b909483af6d8fc19f2e5dca838593 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Mon, 20 Feb 2023 19:09:00 +0100 Subject: [PATCH] random: Do math as unsigned Hahah bits go brrrr --- fish-rust/src/builtins/random.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/fish-rust/src/builtins/random.rs b/fish-rust/src/builtins/random.rs index bcded00c5..9eb498255 100644 --- a/fish-rust/src/builtins/random.rs +++ b/fish-rust/src/builtins/random.rs @@ -165,10 +165,7 @@ fn parse( }; // Safe because end was a valid i64 and the result here is in the range start..=end. - let result: i64 = start - .checked_add_unsigned(rand * step) - .and_then(|x| x.try_into().ok()) - .unwrap(); + let result: i64 = (start as u64 + (rand * step) as u64) as i64; streams.out.append(sprintf!(L!("%d\n"), result)); return STATUS_CMD_OK;