mirror of
https://github.com/chatmail/core.git
synced 2026-04-26 09:56:35 +03:00
Increase dc_context_t reference count during dc_configure()
This fixes use-after-free in case dc_context_unref() is called while the background process spawned by dc_configure() is still running. Corresponding regression test in Python can be run with `pytest tests/test_1_online.py::test_configure_unref`.
This commit is contained in:
@@ -428,9 +428,10 @@ pub unsafe extern "C" fn dc_configure(context: *mut dc_context_t) {
|
||||
return;
|
||||
}
|
||||
|
||||
let ctx = &*context;
|
||||
// Clone the context Arc so we do not use the reference after dc_configure() returns.
|
||||
let ctx = (*context).clone();
|
||||
|
||||
spawn(async move { ctx.configure().await.log_err(ctx, "Configure failed") });
|
||||
spawn(async move { ctx.configure().await.log_err(&ctx, "Configure failed") });
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
||||
Reference in New Issue
Block a user