mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-12 12:01:52 +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.
|
||||
auto maybe_buffer = [&]() -> ErrorOr<ByteBuffer> {
|
||||
if (auto buffer = WebIDL::underlying_buffer_source(chunk.as_object()))
|
||||
return compress(buffer->buffer(), Finish::No);
|
||||
return ByteBuffer {};
|
||||
auto chunk_buffer = TRY(WebIDL::get_buffer_source_copy(chunk.as_object()));
|
||||
return compress(move(chunk_buffer), Finish::No);
|
||||
}();
|
||||
if (maybe_buffer.is_error())
|
||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Unable to compress chunk: {}", maybe_buffer.error())) };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue