From 0ba8201797ff05fba62269caa7fecea988a02125 Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Wed, 22 Mar 2023 17:34:00 +0100 Subject: [PATCH] fix(dc_receive_backup): Increase refcount before spawn Otherwise it is possible for the context that is used in the spawn to be unreferenced. Really this should be caught by the borrow checker that ensures we only spawn things with a 'static lifetime, but we're handling raw pointers so it doesn't. --- deltachat-ffi/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index 09ec1a805..d9f445813 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -4248,10 +4248,11 @@ pub unsafe extern "C" fn dc_receive_backup( Ok(qr) => qr, Err(_) => return 0, }; + let ctx = ctx.clone(); spawn(async move { - imex::get_backup(ctx, qr) + imex::get_backup(&ctx, qr) .await - .log_err(ctx, "Get backup failed") + .log_err(&ctx, "Get backup failed") .ok(); }); 1