From 879ae94183a711122dd7be11566fc59178c09309 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Sun, 3 Nov 2024 09:44:24 +0100 Subject: [PATCH] LibRequests: Don't crash on requests without a read stream finishing This can now happen due to the hostname not existing, as RS explicitly performs DNS resolution before setting up the response pipe. --- Libraries/LibRequests/Request.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/LibRequests/Request.cpp b/Libraries/LibRequests/Request.cpp index 1c711472d7e..4adf079f2c7 100644 --- a/Libraries/LibRequests/Request.cpp +++ b/Libraries/LibRequests/Request.cpp @@ -123,7 +123,7 @@ void Request::set_up_internal_stream_data(DataReceived on_data_available) }; m_internal_stream_data->on_finish = [this, user_on_finish = move(user_on_finish)]() { - if (!m_internal_stream_data->user_finish_called && m_internal_stream_data->read_stream->is_eof()) { + if (!m_internal_stream_data->user_finish_called && (!m_internal_stream_data->read_stream || m_internal_stream_data->read_stream->is_eof())) { m_internal_stream_data->user_finish_called = true; user_on_finish(m_internal_stream_data->total_size, m_internal_stream_data->network_error); }