diff --git a/src/lib.rs b/src/lib.rs index 17dc0ccd..f33d7cca 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1341,9 +1341,11 @@ pub fn z85_decode(data: &str) -> result::Result, DecodeError> { let mut dest = vec![0u8; len]; let c_str = ffi::CString::new(data)?; + let c_str_ptr = c_str.into_raw(); unsafe { - zmq_sys::zmq_z85_decode(dest.as_mut_ptr(), c_str.into_raw()); + zmq_sys::zmq_z85_decode(dest.as_mut_ptr(), c_str_ptr); + drop(ffi::CString::from_raw(c_str_ptr)); } Ok(dest)