浏览代码

Merge #577

577: rand: fix overflow (issue #576) r=Dirbaio a=thibautvdv

Fixes #576 

Co-authored-by: Thibaut Vandervelden <thvdveld@vub.be>
bors[bot] 3 年之前
父节点
当前提交
de109858ca
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/rand.rs

+ 1 - 1
src/rand.rs

@@ -17,7 +17,7 @@ impl Rand {
         const M: u64 = 0xbb2efcec3c39611d;
         const A: u64 = 0x7590ef39;
 
-        let s = self.state * M + A;
+        let s = self.state.wrapping_mul(M).wrapping_add(A);
         self.state = s;
 
         let shift = 29 - (s >> 61);