Fix potential use-after-free in dc_jsonrpc_request()

This commit is contained in:
link2xt
2023-03-13 13:07:26 +00:00
parent 474faefca8
commit 0afd3d595f

View File

@@ -4653,8 +4653,12 @@ mod jsonrpc {
return;
}
let api = &*jsonrpc_instance;
let handle = &api.handle;
let handle = &(*jsonrpc_instance).handle;
// Clone the handle so we do not use the reference
// in spawned task after return from dc_jsonrpc_request().
let handle = handle.clone();
let request = to_string_lossy(request);
spawn(async move {
handle.handle_incoming(&request).await;