From 474faefca8bf94b13303b41b8e51302475e12920 Mon Sep 17 00:00:00 2001 From: link2xt Date: Mon, 13 Mar 2023 12:36:26 +0000 Subject: [PATCH] Increase dc_context_t reference count during dc_imex() --- deltachat-ffi/src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index 630a66f33..e4467fa17 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -2197,13 +2197,14 @@ pub unsafe extern "C" fn dc_imex( }; let passphrase = to_opt_string_lossy(param2); - let ctx = &*context; + // Clone the context Arc so we do not use the reference after dc_imex() returns. + let ctx = (*context).clone(); if let Some(param1) = to_opt_string_lossy(param1) { spawn(async move { - imex::imex(ctx, what, param1.as_ref(), passphrase) + imex::imex(&ctx, what, param1.as_ref(), passphrase) .await - .log_err(ctx, "IMEX failed") + .log_err(&ctx, "IMEX failed") }); } else { eprintln!("dc_imex called without a valid directory");