Przeglądaj źródła

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.
Idan Horowitz 4 lat temu
rodzic
commit
ea5f83616e
2 zmienionych plików z 4 dodań i 2 usunięć
  1. 2 1
      AK/BitStream.h
  2. 2 1
      Userland/Libraries/LibCompress/Deflate.cpp

+ 2 - 1
AK/BitStream.h

@@ -118,7 +118,8 @@ public:
 
 
     bool handle_any_error() override
     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:
 private:

+ 2 - 1
Userland/Libraries/LibCompress/Deflate.cpp

@@ -323,7 +323,8 @@ bool DeflateDecompressor::unreliable_eof() const { return m_state == State::Idle
 
 
 bool DeflateDecompressor::handle_any_error()
 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<ByteBuffer> DeflateDecompressor::decompress_all(ReadonlyBytes bytes)
 Optional<ByteBuffer> DeflateDecompressor::decompress_all(ReadonlyBytes bytes)