From: Jason Ish Date: Mon, 8 Jun 2020 16:57:00 +0000 (-0600) Subject: jsonbuilder: use Box::from_raw instead of transmute to free X-Git-Tag: suricata-6.0.0-beta1~336 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f184bcc10e9fd7210e18730db4d183bc7e3cec3e;p=thirdparty%2Fsuricata.git jsonbuilder: use Box::from_raw instead of transmute to free I think this is a bad use of transmute, while the end result is the same, Box::from_raw is more correct as we created this pointer with Box::into_raw. --- diff --git a/rust/src/jsonbuilder.rs b/rust/src/jsonbuilder.rs index 003c6a00dd..3394383ce6 100644 --- a/rust/src/jsonbuilder.rs +++ b/rust/src/jsonbuilder.rs @@ -554,7 +554,7 @@ pub extern "C" fn jb_clone(js: &mut JsonBuilder) -> *mut JsonBuilder { #[no_mangle] pub unsafe extern "C" fn jb_free(js: &mut JsonBuilder) { - let _: Box = std::mem::transmute(js); + let _ = Box::from_raw(js); } #[no_mangle]