From 6e6ff844d336b0d7b466156daea402e3eff09735 Mon Sep 17 00:00:00 2001 From: Max Wipfli Date: Sat, 5 Jun 2021 15:50:57 +0200 Subject: [PATCH] WebServer: Defer invocation of Client::remove_from_parent() This is necessary to avoid trying to destruct the on_ready_to_read function from inside the function. This fixes #7810. --- Userland/Services/WebServer/Client.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Userland/Services/WebServer/Client.cpp b/Userland/Services/WebServer/Client.cpp index c99a6c0d4a..89594ce227 100644 --- a/Userland/Services/WebServer/Client.cpp +++ b/Userland/Services/WebServer/Client.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, Andreas Kling + * Copyright (c) 2021, Max Wipfli * * SPDX-License-Identifier: BSD-2-Clause */ @@ -33,7 +34,10 @@ Client::Client(NonnullRefPtr socket, String const& root, Core:: void Client::die() { - remove_from_parent(); + deferred_invoke([this](auto& object) { + NonnullRefPtr protector { object }; + remove_from_parent(); + }); } void Client::start()