diff --git a/regex-capi/src/error.rs b/regex-capi/src/error.rs index 2ca3fae80..a269a3913 100644 --- a/regex-capi/src/error.rs +++ b/regex-capi/src/error.rs @@ -54,7 +54,7 @@ ffi_fn! { ffi_fn! { fn rure_error_free(err: *mut Error) { - unsafe { Box::from_raw(err); } + unsafe { drop(Box::from_raw(err)); } } } diff --git a/regex-capi/src/rure.rs b/regex-capi/src/rure.rs index dc49b20a3..d2e1539ed 100644 --- a/regex-capi/src/rure.rs +++ b/regex-capi/src/rure.rs @@ -151,7 +151,7 @@ ffi_fn! { ffi_fn! { fn rure_free(re: *const Regex) { - unsafe { Box::from_raw(re as *mut Regex); } + unsafe { drop(Box::from_raw(re as *mut Regex)); } } } @@ -257,10 +257,10 @@ ffi_fn! { fn rure_iter_capture_names_free(it: *mut IterCaptureNames) { unsafe { let it = &mut *it; - while let Some(ptr) = it.name_ptrs.pop(){ - CString::from_raw(ptr); + while let Some(ptr) = it.name_ptrs.pop() { + drop(CString::from_raw(ptr)); } - Box::from_raw(it); + drop(Box::from_raw(it)); } } } @@ -316,7 +316,7 @@ ffi_fn! { ffi_fn! { fn rure_iter_free(it: *mut Iter) { - unsafe { Box::from_raw(it); } + unsafe { drop(Box::from_raw(it)); } } } @@ -407,7 +407,7 @@ ffi_fn! { ffi_fn! { fn rure_captures_free(captures: *const Captures) { - unsafe { Box::from_raw(captures as *mut Captures); } + unsafe { drop(Box::from_raw(captures as *mut Captures)); } } } @@ -447,7 +447,7 @@ ffi_fn! { ffi_fn! { fn rure_options_free(options: *mut Options) { - unsafe { Box::from_raw(options); } + unsafe { drop(Box::from_raw(options)); } } } @@ -527,7 +527,7 @@ ffi_fn! { ffi_fn! { fn rure_set_free(re: *const RegexSet) { - unsafe { Box::from_raw(re as *mut RegexSet); } + unsafe { drop(Box::from_raw(re as *mut RegexSet)); } } } @@ -624,6 +624,6 @@ fn rure_escape( ffi_fn! { fn rure_cstring_free(s: *mut c_char) { - unsafe { CString::from_raw(s); } + unsafe { drop(CString::from_raw(s)); } } }