mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
LibWeb: Do not move heap functions into other heap functions in Fetch
In particular, the processBody callback here *can't* move the processBodyError callback. It is needed a few lines after. Passing by value is safe and intended here.
This commit is contained in:
parent
f0bfb7f697
commit
49ff5eb4d8
|
|
@ -568,7 +568,7 @@ WebIDL::ExceptionOr<GC::Ptr<PendingResponse>> main_fetch(JS::Realm& realm, Infra
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Let processBody given bytes be these steps:
|
// 3. Let processBody given bytes be these steps:
|
||||||
auto process_body = GC::create_function(vm.heap(), [&realm, request, response, &fetch_params, process_body_error = move(process_body_error)](ByteBuffer bytes) {
|
auto process_body = GC::create_function(vm.heap(), [&realm, request, response, &fetch_params, process_body_error](ByteBuffer bytes) {
|
||||||
// 1. If bytes do not match request’s integrity metadata, then run processBodyError and abort these steps.
|
// 1. If bytes do not match request’s integrity metadata, then run processBodyError and abort these steps.
|
||||||
if (!TRY_OR_IGNORE(SRI::do_bytes_match_metadata_list(bytes, request->integrity_metadata()))) {
|
if (!TRY_OR_IGNORE(SRI::do_bytes_match_metadata_list(bytes, request->integrity_metadata()))) {
|
||||||
process_body_error->function()({});
|
process_body_error->function()({});
|
||||||
|
|
@ -766,7 +766,7 @@ void fetch_response_handover(JS::Realm& realm, Infrastructure::FetchParams const
|
||||||
// 3. If internalResponse's body is null, then queue a fetch task to run processBody given null, with
|
// 3. If internalResponse's body is null, then queue a fetch task to run processBody given null, with
|
||||||
// fetchParams’s task destination.
|
// fetchParams’s task destination.
|
||||||
if (!internal_response->body()) {
|
if (!internal_response->body()) {
|
||||||
Infrastructure::queue_fetch_task(fetch_params.controller(), task_destination, GC::create_function(vm.heap(), [process_body = move(process_body)]() {
|
Infrastructure::queue_fetch_task(fetch_params.controller(), task_destination, GC::create_function(vm.heap(), [process_body]() {
|
||||||
process_body->function()({});
|
process_body->function()({});
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user