Skip to content

Commit

Permalink
Fixed memory leak in z85_decode.
Browse files Browse the repository at this point in the history
  • Loading branch information
icmccorm committed Dec 5, 2023
1 parent 4b873ae commit 175e603
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1341,9 +1341,11 @@ pub fn z85_decode(data: &str) -> result::Result<Vec<u8>, 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)
Expand Down

0 comments on commit 175e603

Please sign in to comment.