delay return until after forgets

This commit is contained in:
Benjamin Fry 2017-03-26 00:20:49 -07:00 committed by Bastian Köcher
parent 6abac82f13
commit 53adf0e6a4
1 changed files with 4 additions and 2 deletions

View File

@ -121,13 +121,15 @@ impl X509StoreContextRef {
unsafe {
ffi::init();
let context = try!(cvt_p(ffi::X509_STORE_CTX_new()).map(|p| X509StoreContext(p)));
try!(cvt(ffi::X509_STORE_CTX_init(context.as_ptr(), trust.as_ptr(), cert.as_ptr(), cert_chain.as_ptr()))
.map(|_| ()));
let init_result = cvt(ffi::X509_STORE_CTX_init(context.as_ptr(), trust.as_ptr(), cert.as_ptr(), cert_chain.as_ptr()))
.map(|_| ());
mem::forget(trust);
mem::forget(cert);
mem::forget(cert_chain);
try!(init_result);
// verify_cert returns an error `<= 0` if there was a validation error
try!(cvt(ffi::X509_verify_cert(context.as_ptr())).map(|_| ()));