Crash on null pointer inside destroy
functions.
This commit is contained in:
parent
c2dbf2c304
commit
0e0316991a
2 changed files with 3 additions and 5 deletions
|
@ -913,9 +913,7 @@ pub unsafe extern "C" fn changelist_entry_at(tx_report: *mut TransactionChange,
|
||||||
/// destroy function for releasing the memory for `repr(C)` structs.
|
/// destroy function for releasing the memory for `repr(C)` structs.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn destroy(obj: *mut c_void) {
|
pub unsafe extern "C" fn destroy(obj: *mut c_void) {
|
||||||
if !obj.is_null() {
|
|
||||||
let _ = Box::from_raw(obj);
|
let _ = Box::from_raw(obj);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a function with a given `$name` that releases the memroy for a type `$t`.
|
/// Creates a function with a given `$name` that releases the memroy for a type `$t`.
|
||||||
|
@ -923,7 +921,7 @@ macro_rules! define_destructor (
|
||||||
($name:ident, $t:ty) => (
|
($name:ident, $t:ty) => (
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn $name(obj: *mut $t) {
|
pub unsafe extern "C" fn $name(obj: *mut $t) {
|
||||||
if !obj.is_null() { let _ = Box::from_raw(obj); }
|
let _ = Box::from_raw(obj);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -28,7 +28,7 @@ pub mod strings {
|
||||||
CString::new(r_string.into()).unwrap().into_raw()
|
CString::new(r_string.into()).unwrap().into_raw()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn kw_from_string(keyword_string: &'static str) -> NamespacedKeyword {
|
pub fn kw_from_string(keyword_string: &'static str) -> Keyword {
|
||||||
// TODO: validate. The input might not be a keyword!
|
// TODO: validate. The input might not be a keyword!
|
||||||
let attr_name = keyword_string.trim_left_matches(":");
|
let attr_name = keyword_string.trim_left_matches(":");
|
||||||
let parts: Vec<&str> = attr_name.split("/").collect();
|
let parts: Vec<&str> = attr_name.split("/").collect();
|
||||||
|
|
Loading…
Reference in a new issue