mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:17:46 +00:00
ProtocolServer: Fix null dereference in HTTP/HTTPS job finish callback
The consolidation of the initialization code between HTTP and HTTPS downloads was capturing the "job" local by reference, which was not safe after we left the init() scope. Fix this by getting the HTTP::Job from the Download object instead.
This commit is contained in:
parent
e8512b8cd7
commit
971425d7b1
3 changed files with 9 additions and 5 deletions
|
@ -42,14 +42,14 @@ namespace ProtocolServer::Detail {
|
|||
template<typename TSelf, typename TJob>
|
||||
void init(TSelf* self, TJob job)
|
||||
{
|
||||
job->on_headers_received = [&](auto& headers, auto response_code) {
|
||||
job->on_headers_received = [self](auto& headers, auto response_code) {
|
||||
if (response_code.has_value())
|
||||
self->set_status_code(response_code.value());
|
||||
self->set_response_headers(headers);
|
||||
};
|
||||
|
||||
job->on_finish = [&](bool success) {
|
||||
if (auto* response = job->response()) {
|
||||
job->on_finish = [self](bool success) {
|
||||
if (auto* response = self->job().response()) {
|
||||
self->set_status_code(response->code());
|
||||
self->set_response_headers(response->headers());
|
||||
self->set_downloaded_size(self->output_stream().size());
|
||||
|
@ -62,11 +62,11 @@ void init(TSelf* self, TJob job)
|
|||
|
||||
self->did_finish(success);
|
||||
};
|
||||
job->on_progress = [&](Optional<u32> total, u32 current) {
|
||||
job->on_progress = [self](Optional<u32> total, u32 current) {
|
||||
self->did_progress(total, current);
|
||||
};
|
||||
if constexpr (requires { job->on_certificate_requested; }) {
|
||||
job->on_certificate_requested = [&](auto&) {
|
||||
job->on_certificate_requested = [self](auto&) {
|
||||
self->did_request_certificates();
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue