RequestServer: Account for null sockets in recreate_socket_if_needed()

A connection's socket is allowed to be null if it's being recreated
after a failed connect(), this was handled correctly in
request_did_finish but not in recreate_socket_if_needed; this commit
fixes this oversight.
This commit is contained in:
Ali Mohammad Pur 2024-05-20 18:58:34 +02:00 committed by Andreas Kling
parent 210a5d77dc
commit 960a4b636c
Notes: sideshowbarker 2024-07-16 23:44:30 +09:00

View file

@ -188,7 +188,7 @@ ErrorOr<void> recreate_socket_if_needed(T& connection, URL::URL const& url)
using SocketType = typename T::SocketType;
using SocketStorageType = typename T::StorageType;
if (!connection.socket->is_open() || connection.socket->is_eof()) {
if (!connection.socket || !connection.socket->is_open() || connection.socket->is_eof()) {
connection.socket = nullptr;
// Create another socket for the connection.
auto set_socket = [&](NonnullOwnPtr<SocketStorageType>&& socket) -> ErrorOr<void> {