LibWeb: Use get_buffer_source_copy for getting the actual byte buffer

`WebIDL::underlying_buffer_source` gets the underlying buffer source
which is not resized according to, for example, `subarray`.
This commit is contained in:
devgianlu 2025-03-01 19:26:17 +01:00 committed by Jelle Raaijmakers
parent e02521911a
commit 033ba43faf
Notes: github-actions[bot] 2025-03-19 12:47:55 +00:00
3 changed files with 8 additions and 12 deletions

View file

@ -117,11 +117,8 @@ WebIDL::ExceptionOr<void> DecompressionStream::decompress_and_enqueue_chunk(JS::
// 2. Let buffer be the result of decompressing chunk with ds's format and context. If this results in an error,
// then throw a TypeError.
auto maybe_buffer = [&]() -> ErrorOr<ByteBuffer> {
auto chunk_buffer = WebIDL::underlying_buffer_source(chunk.as_object());
if (!chunk_buffer)
return ByteBuffer {};
TRY(m_input_stream->write_until_depleted(chunk_buffer->buffer()));
auto chunk_buffer = TRY(WebIDL::get_buffer_source_copy(chunk.as_object()));
TRY(m_input_stream->write_until_depleted(move(chunk_buffer)));
auto decompressed = TRY(ByteBuffer::create_uninitialized(4096));
auto size = TRY(m_decompressor.visit([&](auto const& decompressor) -> ErrorOr<size_t> {