Merge pull request #3710 from youknowone/fix-hash

Fix lcg_random overflow
This commit is contained in:
Jeong YunWon
2022-05-17 06:19:04 +09:00
committed by GitHub

View File

@@ -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;
}
}