diff options
| author | Steven Fackler <[email protected]> | 2018-02-12 09:32:26 -0800 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2018-02-12 11:03:09 -0800 |
| commit | 62514d376e8d94efe303043b2b1e160de4734175 (patch) | |
| tree | 0b3944f34ccbddda6fceb9309de226b01563b6d3 | |
| parent | Release v0.9.23 (diff) | |
| download | rust-openssl-62514d376e8d94efe303043b2b1e160de4734175.tar.xz rust-openssl-62514d376e8d94efe303043b2b1e160de4734175.zip | |
Don't leak X509s
(cherry picked from commit b1ab0ec473fb768c24e8f20576e5652a6d0fb9ab)
| -rw-r--r-- | openssl/src/x509/store.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/openssl/src/x509/store.rs b/openssl/src/x509/store.rs index 198679b5..148c5314 100644 --- a/openssl/src/x509/store.rs +++ b/openssl/src/x509/store.rs @@ -36,11 +36,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(|_| ()) } } |