Skip to content

Commit

Permalink
ProtocolServer: Don't crash on failed request
Browse files Browse the repository at this point in the history
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 "->"
  • Loading branch information
awesomekling committed Nov 30, 2019
1 parent b09ac26 commit 4104f53
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Servers/ProtocolServer/HttpDownload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
}
Expand Down

0 comments on commit 4104f53

Please sign in to comment.