mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-24 18:02:20 +00:00
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:
parent
e02521911a
commit
033ba43faf
Notes:
github-actions[bot]
2025-03-19 12:47:55 +00:00
Author: https://github.com/devgianlu
Commit: 033ba43faf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3755
Reviewed-by: https://github.com/gmta ✅
Reviewed-by: https://github.com/trflynn89
3 changed files with 8 additions and 12 deletions
|
@ -115,9 +115,8 @@ WebIDL::ExceptionOr<void> CompressionStream::compress_and_enqueue_chunk(JS::Valu
|
||||||
|
|
||||||
// 2. Let buffer be the result of compressing chunk with cs's format and context.
|
// 2. Let buffer be the result of compressing chunk with cs's format and context.
|
||||||
auto maybe_buffer = [&]() -> ErrorOr<ByteBuffer> {
|
auto maybe_buffer = [&]() -> ErrorOr<ByteBuffer> {
|
||||||
if (auto buffer = WebIDL::underlying_buffer_source(chunk.as_object()))
|
auto chunk_buffer = TRY(WebIDL::get_buffer_source_copy(chunk.as_object()));
|
||||||
return compress(buffer->buffer(), Finish::No);
|
return compress(move(chunk_buffer), Finish::No);
|
||||||
return ByteBuffer {};
|
|
||||||
}();
|
}();
|
||||||
if (maybe_buffer.is_error())
|
if (maybe_buffer.is_error())
|
||||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Unable to compress chunk: {}", maybe_buffer.error())) };
|
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Unable to compress chunk: {}", maybe_buffer.error())) };
|
||||||
|
|
|
@ -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,
|
// 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.
|
// then throw a TypeError.
|
||||||
auto maybe_buffer = [&]() -> ErrorOr<ByteBuffer> {
|
auto maybe_buffer = [&]() -> ErrorOr<ByteBuffer> {
|
||||||
auto chunk_buffer = WebIDL::underlying_buffer_source(chunk.as_object());
|
auto chunk_buffer = TRY(WebIDL::get_buffer_source_copy(chunk.as_object()));
|
||||||
if (!chunk_buffer)
|
TRY(m_input_stream->write_until_depleted(move(chunk_buffer)));
|
||||||
return ByteBuffer {};
|
|
||||||
|
|
||||||
TRY(m_input_stream->write_until_depleted(chunk_buffer->buffer()));
|
|
||||||
|
|
||||||
auto decompressed = TRY(ByteBuffer::create_uninitialized(4096));
|
auto decompressed = TRY(ByteBuffer::create_uninitialized(4096));
|
||||||
auto size = TRY(m_decompressor.visit([&](auto const& decompressor) -> ErrorOr<size_t> {
|
auto size = TRY(m_decompressor.visit([&](auto const& decompressor) -> ErrorOr<size_t> {
|
||||||
|
|
|
@ -2,7 +2,7 @@ Harness status: OK
|
||||||
|
|
||||||
Found 3 tests
|
Found 3 tests
|
||||||
|
|
||||||
3 Fail
|
3 Pass
|
||||||
Fail deflate compression with large flush output
|
Pass deflate compression with large flush output
|
||||||
Fail gzip compression with large flush output
|
Pass gzip compression with large flush output
|
||||||
Fail deflate-raw compression with large flush output
|
Pass deflate-raw compression with large flush output
|
Loading…
Add table
Add a link
Reference in a new issue