Skip to content

Commit

Permalink
Use ForeignType::into_ptr wherever applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
rushilmehra committed Sep 4, 2024
1 parent e5b6627 commit 7324db2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
3 changes: 1 addition & 2 deletions boring/src/dsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,7 @@ impl Dsa<Public> {
let dsa = Dsa::from_ptr(cvt_p(ffi::DSA_new())?);
cvt(DSA_set0_pqg(dsa.0, p.as_ptr(), q.as_ptr(), g.as_ptr()))?;
mem::forget((p, q, g));
cvt(DSA_set0_key(dsa.0, pub_key.as_ptr(), ptr::null_mut()))?;
mem::forget(pub_key);
cvt(DSA_set0_key(dsa.0, pub_key.into_ptr(), ptr::null_mut()))?;
Ok(dsa)
}
}
Expand Down
15 changes: 6 additions & 9 deletions boring/src/ssl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1068,9 +1068,9 @@ impl SslContextBuilder {
assert!(!self.is_rpk, "This API is not supported for RPK");

unsafe {
let ptr = cert_store.as_ptr();
cvt(ffi::SSL_CTX_set0_verify_cert_store(self.as_ptr(), ptr) as c_int)?;
mem::forget(cert_store);
cvt(
ffi::SSL_CTX_set0_verify_cert_store(self.as_ptr(), cert_store.into_ptr()) as c_int,
)?;

Ok(())
}
Expand All @@ -1083,8 +1083,7 @@ impl SslContextBuilder {
assert!(!self.is_rpk, "This API is not supported for RPK");

unsafe {
ffi::SSL_CTX_set_cert_store(self.as_ptr(), cert_store.as_ptr());
mem::forget(cert_store);
ffi::SSL_CTX_set_cert_store(self.as_ptr(), cert_store.into_ptr());
}
}

Expand Down Expand Up @@ -1260,8 +1259,7 @@ impl SslContextBuilder {
assert!(!self.is_rpk, "This API is not supported for RPK");

unsafe {
cvt(ffi::SSL_CTX_add_extra_chain_cert(self.as_ptr(), cert.as_ptr()) as c_int)?;
mem::forget(cert);
cvt(ffi::SSL_CTX_add_extra_chain_cert(self.as_ptr(), cert.into_ptr()) as c_int)?;
Ok(())
}
}
Expand Down Expand Up @@ -2742,8 +2740,7 @@ impl SslRef {
);

unsafe {
cvt(ffi::SSL_set0_verify_cert_store(self.as_ptr(), cert_store.as_ptr()) as c_int)?;
mem::forget(cert_store);
cvt(ffi::SSL_set0_verify_cert_store(self.as_ptr(), cert_store.into_ptr()) as c_int)?;
Ok(())
}
}
Expand Down
4 changes: 1 addition & 3 deletions boring/src/x509/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1584,9 +1584,7 @@ impl GeneralName {
ffi::init();
let gn = cvt_p(ffi::GENERAL_NAME_new())?;
(*gn).type_ = ffi::GEN_RID;
(*gn).d.registeredID = oid.as_ptr();

mem::forget(oid);
(*gn).d.registeredID = oid.into_ptr();

Ok(GeneralName::from_ptr(gn))
}
Expand Down

0 comments on commit 7324db2

Please sign in to comment.