Skip to content

Commit 44ccc40

Browse files
authored
Merge pull request RustPython#3710 from youknowone/fix-hash
Fix lcg_random overflow
2 parents 9fd4f7b + cbeeb51 commit 44ccc40

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

common/src/hash.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ pub fn mod_int(value: i64) -> PyHash {
186186

187187
pub fn lcg_urandom(mut x: u32, buf: &mut [u8]) {
188188
for b in buf {
189-
x *= 214013;
190-
x += 2531011;
189+
x = x.wrapping_mul(214013);
190+
x = x.wrapping_add(2531011);
191191
*b = ((x >> 16) & 0xff) as u8;
192192
}
193193
}

0 commit comments

Comments
 (0)