Skip to content

Commit 03493c3

Browse files
nicholasbishopGabrielMajeri
authored andcommitted
Fix incorrect pointer cast in get_rng
When passing in a specific algorithm type to the get_rng function, a pointer to the `Option`-wrapped value was incorrectly being passed in. The pointer should be to the `RngAlgorithmType` inside the `Option` instead. Fixes #446
1 parent 2ae8fc7 commit 03493c3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/proto/rng.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ impl Rng {
122122
pub fn get_rng(&mut self, algorithm: Option<RngAlgorithmType>, buffer: &mut [u8]) -> Result {
123123
let buffer_length = buffer.len();
124124

125-
let algo = match algorithm {
125+
let algo = match algorithm.as_ref() {
126126
None => ptr::null(),
127-
Some(algo) => &algo as *const RngAlgorithmType,
127+
Some(algo) => algo as *const RngAlgorithmType,
128128
};
129129

130130
unsafe { (self.get_rng)(self, algo, buffer_length, buffer.as_mut_ptr()).into() }

0 commit comments

Comments
 (0)