From cbeeb51cee708d7d6b55b9e1419895ff2768ccbf Mon Sep 17 00:00:00 2001 From: Jeong Yunwon Date: Tue, 17 May 2022 05:53:13 +0900 Subject: [PATCH] Fix lcg_random overflow --- common/src/hash.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/hash.rs b/common/src/hash.rs index c0b7945faf..c3f13e74d5 100644 --- a/common/src/hash.rs +++ b/common/src/hash.rs @@ -186,8 +186,8 @@ pub fn mod_int(value: i64) -> PyHash { pub fn lcg_urandom(mut x: u32, buf: &mut [u8]) { for b in buf { - x *= 214013; - x += 2531011; + x = x.wrapping_mul(214013); + x = x.wrapping_add(2531011); *b = ((x >> 16) & 0xff) as u8; } }