Make it compile again.

Make self mut in set_subject_name.
Add assert to prevent a null pointer in subject_name.
This commit is contained in:
mredlek 2017-02-07 21:49:07 +01:00
parent 30a634c877
commit 8ae424235e
2 changed files with 9 additions and 2 deletions

View File

@ -93,7 +93,13 @@ impl Asn1StringRef {
} }
} }
type_!(Asn1Integer, Asn1IntegerRef, ffi::ASN1_INTEGER, ffi::ASN1_INTEGER_free); foreign_type! {
type CType = ffi::ASN1_INTEGER;
fn drop = ffi::ASN1_INTEGER_free;
pub struct Asn1Integer;
pub struct Asn1IntegerRef;
}
impl Asn1IntegerRef { impl Asn1IntegerRef {
pub fn get(&self) -> i64 { pub fn get(&self) -> i64 {

View File

@ -647,11 +647,12 @@ impl X509ReqRef {
pub fn subject_name(&self) -> &X509NameRef { pub fn subject_name(&self) -> &X509NameRef {
unsafe { unsafe {
let name = compat::X509_REQ_get_subject_name(self.as_ptr()); let name = compat::X509_REQ_get_subject_name(self.as_ptr());
assert!(!name.is_null());
X509NameRef::from_ptr(name) X509NameRef::from_ptr(name)
} }
} }
pub fn set_subject_name(&self, value: &X509NameRef) -> Result<(), ErrorStack> { pub fn set_subject_name(&mut self, value: &X509NameRef) -> Result<(), ErrorStack> {
unsafe { unsafe {
cvt(ffi::X509_REQ_set_subject_name(self.as_ptr(), value.as_ptr())).map(|_| ()) cvt(ffi::X509_REQ_set_subject_name(self.as_ptr(), value.as_ptr())).map(|_| ())
} }