Fix memory leak in general name stack
This commit is contained in:
parent
6b12a0cdde
commit
e5299fd7c9
|
|
@ -1090,6 +1090,8 @@ extern "C" {
|
||||||
pub fn sk_pop_free(st: *mut _STACK, free: Option<unsafe extern "C" fn (*mut c_void)>);
|
pub fn sk_pop_free(st: *mut _STACK, free: Option<unsafe extern "C" fn (*mut c_void)>);
|
||||||
pub fn sk_pop(st: *mut _STACK) -> *mut c_char;
|
pub fn sk_pop(st: *mut _STACK) -> *mut c_char;
|
||||||
|
|
||||||
|
pub fn GENERAL_NAME_free(name: *mut GENERAL_NAME);
|
||||||
|
|
||||||
pub fn SSLeay() -> c_long;
|
pub fn SSLeay() -> c_long;
|
||||||
pub fn SSLeay_version(key: c_int) -> *const c_char;
|
pub fn SSLeay_version(key: c_int) -> *const c_char;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -408,7 +408,7 @@ impl<'a> X509Ref<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(GeneralNames {
|
Some(GeneralNames {
|
||||||
stack: stack as *const _,
|
stack: stack as *mut _,
|
||||||
m: PhantomData,
|
m: PhantomData,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -735,12 +735,23 @@ make_validation_error!(X509_V_OK,
|
||||||
X509ApplicationVerification = X509_V_ERR_APPLICATION_VERIFICATION,
|
X509ApplicationVerification = X509_V_ERR_APPLICATION_VERIFICATION,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// FIXME remove lifetime param for 0.9
|
||||||
/// A collection of OpenSSL `GENERAL_NAME`s.
|
/// A collection of OpenSSL `GENERAL_NAME`s.
|
||||||
pub struct GeneralNames<'a> {
|
pub struct GeneralNames<'a> {
|
||||||
stack: *const ffi::stack_st_GENERAL_NAME,
|
stack: *mut ffi::stack_st_GENERAL_NAME,
|
||||||
m: PhantomData<&'a ()>,
|
m: PhantomData<&'a ()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Drop for GeneralNames<'a> {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
unsafe {
|
||||||
|
let free: unsafe extern "C" fn(*mut ffi::GENERAL_NAME) = ffi::GENERAL_NAME_free;
|
||||||
|
let free: unsafe extern "C" fn(*mut c_void) = mem::transmute(free);
|
||||||
|
ffi::sk_pop_free(&mut (*self.stack).stack, Some(free));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> GeneralNames<'a> {
|
impl<'a> GeneralNames<'a> {
|
||||||
/// Returns the number of `GeneralName`s in this structure.
|
/// Returns the number of `GeneralName`s in this structure.
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue