1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:38:11 +00:00

Streams: Distinguish recoverable and fatal errors.

This commit is contained in:
asynts 2020-08-31 13:12:15 +02:00 committed by Andreas Kling
parent daeb2bdc60
commit 9ce4475907
9 changed files with 75 additions and 59 deletions

View file

@ -77,12 +77,12 @@ size_t GzipDecompressor::read(Bytes bytes)
m_input_stream >> crc32 >> input_size;
if (crc32 != current_member().m_checksum.digest()) {
m_error = true;
set_fatal_error();
return 0;
}
if (input_size != current_member().m_nread) {
m_error = true;
set_fatal_error();
return 0;
}
@ -101,7 +101,7 @@ size_t GzipDecompressor::read(Bytes bytes)
m_input_stream >> Bytes { &header, sizeof(header) };
if (!header.valid_magic_number() || !header.supported_by_implementation()) {
m_error = true;
set_fatal_error();
return 0;
}
@ -129,7 +129,7 @@ size_t GzipDecompressor::read(Bytes bytes)
bool GzipDecompressor::read_or_error(Bytes bytes)
{
if (read(bytes) < bytes.size()) {
m_error = true;
set_fatal_error();
return false;
}
@ -143,7 +143,7 @@ bool GzipDecompressor::discard_or_error(size_t count)
size_t ndiscarded = 0;
while (ndiscarded < count) {
if (eof()) {
m_error = true;
set_fatal_error();
return false;
}