]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
jsonbuilder: use Box::from_raw instead of transmute to free
authorJason Ish <jason.ish@oisf.net>
Mon, 8 Jun 2020 16:57:00 +0000 (10:57 -0600)
committerVictor Julien <victor@inliniac.net>
Tue, 9 Jun 2020 11:29:04 +0000 (13:29 +0200)
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

index 003c6a00ddc1b0490f63d8daa4c229bc1443eadb..3394383ce6aefc6d2ec62480717e0998645e6b82 100644 (file)
@@ -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<JsonBuilder> = std::mem::transmute(js);
+    let _ = Box::from_raw(js);
 }
 
 #[no_mangle]