From 49ff5eb4d8398799b8a3a16dc0fbca8ca00c7c15 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Tue, 30 Apr 2024 07:24:37 -0400 Subject: [PATCH] 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. --- Libraries/LibWeb/Fetch/Fetching/Fetching.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp b/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp index afd2ca7953d..921194c637b 100644 --- a/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp +++ b/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp @@ -568,7 +568,7 @@ WebIDL::ExceptionOr> main_fetch(JS::Realm& realm, Infra } // 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. if (!TRY_OR_IGNORE(SRI::do_bytes_match_metadata_list(bytes, request->integrity_metadata()))) { 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 // fetchParams’s task destination. 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()({}); })); }