瀏覽代碼

LibCompress+AK: Propagate error handling to wrapped streams

This ensures that when a DeflateCompressor stream is cleared of any
errors its underlying wrapped streams (InputBitStream/InputMemoryStream)
will be cleared as well and wont fail a VERIFY on destruction.
Idan Horowitz 4 年之前
父節點
當前提交
a955fd4156
共有 3 個文件被更改,包括 11 次插入0 次删除
  1. 5 0
      AK/BitStream.h
  2. 5 0
      Userland/Libraries/LibCompress/Deflate.cpp
  3. 1 0
      Userland/Libraries/LibCompress/Deflate.h

+ 5 - 0
AK/BitStream.h

@@ -116,6 +116,11 @@ public:
             m_next_byte.clear();
     }
 
+    bool handle_any_error() override
+    {
+        return m_stream.handle_any_error() || Stream::handle_any_error();
+    }
+
 private:
     Optional<u8> m_next_byte;
     size_t m_bit_offset { 0 };

+ 5 - 0
Userland/Libraries/LibCompress/Deflate.cpp

@@ -321,6 +321,11 @@ bool DeflateDecompressor::discard_or_error(size_t count)
 
 bool DeflateDecompressor::unreliable_eof() const { return m_state == State::Idle && m_read_final_bock; }
 
+bool DeflateDecompressor::handle_any_error()
+{
+    return m_input_stream.handle_any_error() || Stream::handle_any_error();
+}
+
 Optional<ByteBuffer> DeflateDecompressor::decompress_all(ReadonlyBytes bytes)
 {
     InputMemoryStream memory_stream { bytes };

+ 1 - 0
Userland/Libraries/LibCompress/Deflate.h

@@ -102,6 +102,7 @@ public:
     bool discard_or_error(size_t) override;
 
     bool unreliable_eof() const override;
+    bool handle_any_error() override;
 
     static Optional<ByteBuffer> decompress_all(ReadonlyBytes);