From ea5f83616e8045ab66fb71994e1cdbcc0efbc326 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Tue, 16 Mar 2021 15:11:08 +0200 Subject: [PATCH] LibCompress+AK: Dont short-circuit error handling propagation In the case that both the stream and the wrapped substream had errors to be handled only one of the two would be resolved due to boolean short circuiting. this commit ensures both are handled irregardless of one another. --- AK/BitStream.h | 3 ++- Userland/Libraries/LibCompress/Deflate.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/AK/BitStream.h b/AK/BitStream.h index 02ba16cb63..4d1684b156 100644 --- a/AK/BitStream.h +++ b/AK/BitStream.h @@ -118,7 +118,8 @@ public: bool handle_any_error() override { - return m_stream.handle_any_error() || Stream::handle_any_error(); + bool handled_errors = m_stream.handle_any_error(); + return Stream::handle_any_error() || handled_errors; } private: diff --git a/Userland/Libraries/LibCompress/Deflate.cpp b/Userland/Libraries/LibCompress/Deflate.cpp index 654c2584df..bee132ee2a 100644 --- a/Userland/Libraries/LibCompress/Deflate.cpp +++ b/Userland/Libraries/LibCompress/Deflate.cpp @@ -323,7 +323,8 @@ bool DeflateDecompressor::unreliable_eof() const { return m_state == State::Idle bool DeflateDecompressor::handle_any_error() { - return m_input_stream.handle_any_error() || Stream::handle_any_error(); + bool handled_errors = m_input_stream.handle_any_error(); + return Stream::handle_any_error() || handled_errors; } Optional DeflateDecompressor::decompress_all(ReadonlyBytes bytes)