fix(imex): dc_decrypt_setup_file: extend lifetime of CString

payload_c binding makes sure the memory is not freed until strdup exits.

See as_ptr documentation:
https://doc.rust-lang.org/std/ffi/struct.CString.html#method.as_ptr
This commit is contained in:
Alexander
2019-07-28 17:47:52 +00:00
committed by Friedel Ziegelmayer
parent 5a8b4748b8
commit 0132106c7e

View File

@@ -490,7 +490,8 @@ pub unsafe fn dc_decrypt_setup_file(
if let Some(plain) =
dc_pgp_symm_decrypt(passphrase, binary as *const libc::c_void, binary_bytes)
{
payload = strdup(CString::new(plain).unwrap().as_ptr());
let payload_c = CString::new(plain).unwrap();
payload = strdup(payload_c.as_ptr());
}
}
}