summaryrefslogtreecommitdiff
path: root/Servers/ProtocolServer
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-11-30 11:02:14 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-11-30 11:02:14 +0100
commit4104f53a945584c74e032bb9a09afd8fc358b1b4 (patch)
tree3ebd3333c99faa370842ddf6a62dff0f20661082 /Servers/ProtocolServer
parentb09ac2631146a2e8ed4fc34935784a35e43b0a16 (diff)
downloadserenity-4104f53a945584c74e032bb9a09afd8fc358b1b4.zip
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 "->"
Diffstat (limited to 'Servers/ProtocolServer')
-rw-r--r--Servers/ProtocolServer/HttpDownload.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/Servers/ProtocolServer/HttpDownload.cpp b/Servers/ProtocolServer/HttpDownload.cpp
index b20c553a58..c4117ccf5b 100644
--- a/Servers/ProtocolServer/HttpDownload.cpp
+++ b/Servers/ProtocolServer/HttpDownload.cpp
@@ -7,7 +7,8 @@ HttpDownload::HttpDownload(PSClientConnection& client, NonnullRefPtr<CHttpJob>&&
, 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);
};
}