From 4b4b12165e9bb0bfb475078498f9f612c6ae2c03 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Mon, 4 Nov 2024 16:10:32 +0100 Subject: [PATCH] LibWeb: Release acquired readers after piping through a stream This very partially implements the spec's "finalize" steps for piping streams. --- Libraries/LibWeb/Streams/AbstractOperations.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Libraries/LibWeb/Streams/AbstractOperations.cpp b/Libraries/LibWeb/Streams/AbstractOperations.cpp index 3ebc1837478..6707c859562 100644 --- a/Libraries/LibWeb/Streams/AbstractOperations.cpp +++ b/Libraries/LibWeb/Streams/AbstractOperations.cpp @@ -315,16 +315,18 @@ GC::Ref readable_stream_pipe_to(ReadableStream& source, Writabl WebIDL::resolve_promise(realm, promise, JS::js_undefined()); }); - auto success_steps = GC::create_function(realm.heap(), [promise, &realm, writer](ByteBuffer) { + auto success_steps = GC::create_function(realm.heap(), [promise, &realm, reader, writer](ByteBuffer) { // Make sure we close the acquired writer. WebIDL::resolve_promise(realm, writable_stream_default_writer_close(*writer), JS::js_undefined()); + readable_stream_default_reader_release(*reader); WebIDL::resolve_promise(realm, promise, JS::js_undefined()); }); - auto failure_steps = GC::create_function(realm.heap(), [promise, &realm, writer](JS::Value error) { + auto failure_steps = GC::create_function(realm.heap(), [promise, &realm, reader, writer](JS::Value error) { // Make sure we close the acquired writer. WebIDL::resolve_promise(realm, writable_stream_default_writer_close(*writer), JS::js_undefined()); + readable_stream_default_reader_release(*reader); WebIDL::reject_promise(realm, promise, error); });