Make the BigNum generation from a native pointer unsafe

This commit is contained in:
Daniel Albert 2016-01-09 22:09:38 +00:00
parent 578fac7e80
commit 1238405637
1 changed files with 6 additions and 8 deletions

View File

@ -102,11 +102,10 @@ impl BigNum {
}) })
} }
pub fn new_from_ffi(orig: *mut ffi::BIGNUM) -> Result<BigNum, SslError> { pub unsafe fn new_from_ffi(orig: *mut ffi::BIGNUM) -> Result<BigNum, SslError> {
if orig.is_null() { if orig.is_null() {
panic!("Null Pointer was supplied to BigNum::new_from_ffi"); panic!("Null Pointer was supplied to BigNum::new_from_ffi");
} }
unsafe {
let r = ffi::BN_dup(orig); let r = ffi::BN_dup(orig);
if r.is_null() { if r.is_null() {
panic!("Unexpected null pointer from BN_dup(..)") panic!("Unexpected null pointer from BN_dup(..)")
@ -114,7 +113,6 @@ impl BigNum {
Ok(BigNum(r)) Ok(BigNum(r))
} }
} }
}
pub fn new_from_slice(n: &[u8]) -> Result<BigNum, SslError> { pub fn new_from_slice(n: &[u8]) -> Result<BigNum, SslError> {
BigNum::new().and_then(|v| unsafe { BigNum::new().and_then(|v| unsafe {