Skip to content

Commit eb4b8a4

Browse files
committed
Fix #1082 (seed_from_u64 with non multiple of 4)
1 parent 34aa769 commit eb4b8a4

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

rand_core/CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [0.6.1] - 2020-12-31
7+
## [0.6.1] - 2021-01-03
8+
### Fixed
9+
- Avoid panic when using `RngCore::seed_from_u64` with a seed which is not a
10+
multiple of four (#1082)
811
### Other
912
- Enable all stable features in the playground (#1081)
1013

rand_core/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ pub trait SeedableRng: Sized {
313313
let xorshifted = (((state >> 18) ^ state) >> 27) as u32;
314314
let rot = (state >> 59) as u32;
315315
let x = xorshifted.rotate_right(rot);
316-
chunk.copy_from_slice(&x.to_le_bytes());
316+
chunk.copy_from_slice(&x.to_le_bytes()[..chunk.len()]);
317317
}
318318

319319
Self::from_seed(seed)

0 commit comments

Comments
 (0)