aboutsummaryrefslogtreecommitdiff
path: root/openssl/src
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2018-02-12 09:50:41 -0800
committerGitHub <[email protected]>2018-02-12 09:50:41 -0800
commit9f167894a2dce1f7f27cd601764e1a394bd6093e (patch)
tree8bbb39b8a6cc5b689983565b81fae5a0f9bc1431 /openssl/src
parentMerge pull request #831 from apeduru/rsa-docs (diff)
parentDon't leak X509s (diff)
downloadrust-openssl-9f167894a2dce1f7f27cd601764e1a394bd6093e.tar.xz
rust-openssl-9f167894a2dce1f7f27cd601764e1a394bd6093e.zip
Merge pull request #836 from sfackler/cert-store-leak
Don't leak X509s
Diffstat (limited to 'openssl/src')
-rw-r--r--openssl/src/x509/store.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/openssl/src/x509/store.rs b/openssl/src/x509/store.rs
index 876e4246..4d6bc9ab 100644
--- a/openssl/src/x509/store.rs
+++ b/openssl/src/x509/store.rs
@@ -30,7 +30,7 @@
//! builder.set_issuer_name(&name).unwrap();
//! builder.set_pubkey(&pkey).unwrap();
//! builder.sign(&pkey, MessageDigest::sha256()).unwrap();
-//!
+//!
//! let certificate: X509 = builder.build();
//!
//! let mut builder = X509StoreBuilder::new().unwrap();
@@ -52,7 +52,7 @@ foreign_type! {
type CType = ffi::X509_STORE;
fn drop = ffi::X509_STORE_free;
- /// A builder type used to construct an `X509Store`.
+ /// A builder type used to construct an `X509Store`.
pub struct X509StoreBuilder;
/// Reference to an `X509StoreBuilder`.
pub struct X509StoreBuilderRef;
@@ -80,11 +80,10 @@ impl X509StoreBuilder {
impl X509StoreBuilderRef {
/// Adds a certificate to the certificate store.
+ // FIXME should take an &X509Ref
pub fn add_cert(&mut self, cert: X509) -> Result<(), ErrorStack> {
unsafe {
- let ptr = cert.as_ptr();
- mem::forget(cert); // the cert will be freed inside of X509_STORE_add_cert on error
- cvt(ffi::X509_STORE_add_cert(self.as_ptr(), ptr)).map(|_| ())
+ cvt(ffi::X509_STORE_add_cert(self.as_ptr(), cert.as_ptr())).map(|_| ())
}
}