From f184bcc10e9fd7210e18730db4d183bc7e3cec3e Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Mon, 8 Jun 2020 10:57:00 -0600 Subject: [PATCH] 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. --- rust/src/jsonbuilder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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] -- 2.47.2