mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibCompress: Error out when encounters and incomplete stream
If we find ourselves in a situation where zlib can't make any progress, we don't have any more data to feed in and no output has been produced, we need to raise an error as the compressed data is incomplete. This used to lead to an infinite busy loop where we keep calling zlib to decompressed but is not able. This causes the promise on the read side of the transformer to never fulfill. This gives us at least 24 more WPT tests :)
This commit is contained in:
Notes:
github-actions[bot]
2025-06-14 22:28:10 +00:00
Author: https://github.com/tete17 🔰 Commit: https://github.com/LadybirdBrowser/ladybird/commit/7a235537e89 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4759 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/devgianlu Reviewed-by: https://github.com/trflynn89 ✅
@@ -153,13 +153,13 @@ WebIDL::ExceptionOr<void> DecompressionStream::decompress_flush_and_enqueue()
|
||||
return TRY(decompressor->read_until_eof());
|
||||
});
|
||||
if (maybe_buffer.is_error())
|
||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Unable to compress flush: {}", maybe_buffer.error())) };
|
||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Unable to decompress flush: {}", maybe_buffer.error())) };
|
||||
|
||||
auto buffer = maybe_buffer.release_value();
|
||||
|
||||
// Note: LibCompress already throws an error if we call read_until_eof and no more progress can be made
|
||||
// 2. If the end of the compressed input has not been reached, then throw a TypeError.
|
||||
if (m_decompressor.visit([](auto const& decompressor) { return !decompressor->is_eof(); }))
|
||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "End of compressed input has not been reached"sv };
|
||||
VERIFY(m_decompressor.visit([](auto const& decompressor) { return decompressor->is_eof(); }));
|
||||
|
||||
// 3. If buffer is empty, return.
|
||||
if (buffer.is_empty())
|
||||
|
||||
Reference in New Issue
Block a user