From 123840563703cd1c129a9702761b2028ab6c7210 Mon Sep 17 00:00:00 2001 From: Daniel Albert Date: Sat, 9 Jan 2016 22:09:38 +0000 Subject: [PATCH] Make the BigNum generation from a native pointer unsafe --- openssl/src/bn/mod.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/openssl/src/bn/mod.rs b/openssl/src/bn/mod.rs index cd1229af..ba1121dd 100644 --- a/openssl/src/bn/mod.rs +++ b/openssl/src/bn/mod.rs @@ -102,17 +102,15 @@ impl BigNum { }) } - pub fn new_from_ffi(orig: *mut ffi::BIGNUM) -> Result { + pub unsafe fn new_from_ffi(orig: *mut ffi::BIGNUM) -> Result { if orig.is_null() { panic!("Null Pointer was supplied to BigNum::new_from_ffi"); } - unsafe { - let r = ffi::BN_dup(orig); - if r.is_null() { - panic!("Unexpected null pointer from BN_dup(..)") - } else { - Ok(BigNum(r)) - } + let r = ffi::BN_dup(orig); + if r.is_null() { + panic!("Unexpected null pointer from BN_dup(..)") + } else { + Ok(BigNum(r)) } }