From e0e09f71be276b04035518814817f8f6ae078663 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 28 May 2025 11:11:12 +0200 Subject: [PATCH] RequestServer: Don't try to self-destruct already-destroyed request --- Services/RequestServer/ConnectionFromClient.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Services/RequestServer/ConnectionFromClient.cpp b/Services/RequestServer/ConnectionFromClient.cpp index daf09cdc3bb..f34b0dcdbe1 100644 --- a/Services/RequestServer/ConnectionFromClient.cpp +++ b/Services/RequestServer/ConnectionFromClient.cpp @@ -99,7 +99,7 @@ ByteString build_curl_resolve_list(DNS::LookupResult const& dns_result, StringVi return resolve_opt_builder.to_byte_string(); } -struct ConnectionFromClient::ActiveRequest { +struct ConnectionFromClient::ActiveRequest : public Weakable { CURLM* multi { nullptr }; CURL* easy { nullptr }; Vector curl_string_lists; @@ -133,9 +133,11 @@ struct ConnectionFromClient::ActiveRequest { void schedule_self_destruction() const { - Core::deferred_invoke([this] { - if (client) - client->m_active_requests.remove(request_id); + Core::deferred_invoke([weak_this = make_weak_ptr()] { + if (!weak_this) + return; + if (weak_this->client) + weak_this->client->m_active_requests.remove(weak_this->request_id); }); }