mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-24 00:49:46 +00:00
LibWeb: Fix GC leaks in Fetch::Infrastructure::Body::fully_read()
By making this function accept the success and error steps as HeapFunction rather than SafeFunction, we break a bunch of strong GC cycles.
This commit is contained in:
parent
0c84508f87
commit
184368285c
Notes:
sideshowbarker
2024-07-17 05:09:48 +09:00
Author: https://github.com/awesomekling
Commit: 184368285c
Pull-request: https://github.com/SerenityOS/serenity/pull/24078
9 changed files with 67 additions and 67 deletions
|
|
@ -85,17 +85,17 @@ void SharedImageRequest::fetch_image(JS::Realm& realm, JS::NonnullGCPtr<Fetch::I
|
|||
// https://github.com/whatwg/html/issues/9355
|
||||
response = response->unsafe_response();
|
||||
|
||||
auto process_body = [this, request, response](ByteBuffer data) {
|
||||
auto process_body = JS::create_heap_function(heap(), [this, request, response](ByteBuffer data) {
|
||||
auto extracted_mime_type = response->header_list()->extract_mime_type().release_value_but_fixme_should_propagate_errors();
|
||||
auto mime_type = extracted_mime_type.has_value() ? extracted_mime_type.value().essence().bytes_as_string_view() : StringView {};
|
||||
handle_successful_fetch(request->url(), mime_type, move(data));
|
||||
};
|
||||
auto process_body_error = [this](auto) {
|
||||
});
|
||||
auto process_body_error = JS::create_heap_function(heap(), [this](JS::GCPtr<WebIDL::DOMException>) {
|
||||
handle_failed_fetch();
|
||||
};
|
||||
});
|
||||
|
||||
if (response->body())
|
||||
response->body()->fully_read(realm, move(process_body), move(process_body_error), JS::NonnullGCPtr { realm.global_object() }).release_value_but_fixme_should_propagate_errors();
|
||||
response->body()->fully_read(realm, process_body, process_body_error, JS::NonnullGCPtr { realm.global_object() }).release_value_but_fixme_should_propagate_errors();
|
||||
else
|
||||
handle_failed_fetch();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue