From 4104f53a945584c74e032bb9a09afd8fc358b1b4 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 30 Nov 2019 11:02:14 +0100 Subject: [PATCH] ProtocolServer: Don't crash on failed request The CNetworkJob::on_finish hook will be invoked both for success and failure, but there will only be a m_job->response() in the success case so we have to null-check it before using it. This should have been obvious from the "->" --- Servers/ProtocolServer/HttpDownload.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Servers/ProtocolServer/HttpDownload.cpp b/Servers/ProtocolServer/HttpDownload.cpp index b20c553a586025..c4117ccf5bde98 100644 --- a/Servers/ProtocolServer/HttpDownload.cpp +++ b/Servers/ProtocolServer/HttpDownload.cpp @@ -7,7 +7,8 @@ HttpDownload::HttpDownload(PSClientConnection& client, NonnullRefPtr&& , m_job(job) { m_job->on_finish = [this](bool success) { - set_payload(m_job->response()->payload()); + if (m_job->response()) + set_payload(m_job->response()->payload()); did_finish(success); }; }