diff --git a/components/core/src/clp/streaming_compression/lzma/Compressor.cpp b/components/core/src/clp/streaming_compression/lzma/Compressor.cpp index 65445061a..8d518249c 100644 --- a/components/core/src/clp/streaming_compression/lzma/Compressor.cpp +++ b/components/core/src/clp/streaming_compression/lzma/Compressor.cpp @@ -156,6 +156,9 @@ auto Compressor::write(char const* data, size_t data_length) -> void { } auto Compressor::flush() -> void { + if (nullptr == m_compressed_stream_file_writer) { + throw OperationFailed(ErrorCode_NotInit, __FILENAME__, __LINE__); + } flush_lzma(LZMA_SYNC_FLUSH); } @@ -228,7 +231,7 @@ auto Compressor::flush_lzma(lzma_action flush_action) -> void { case LZMA_BUF_ERROR: // No encoding progress can be made // NOTE: this can happen if we are using LZMA_FULL_FLUSH or // LZMA_FULL_BARRIER. These two actions keeps encoding input - // data alongside flushing already encoded but buffered data. + // data alongside flushing buffered encoded data. SPDLOG_ERROR("LZMA compressor input stream is corrupt."); throw OperationFailed(ErrorCode_Failure, __FILENAME__, __LINE__); default: diff --git a/components/core/src/clp/streaming_compression/lzma/Compressor.hpp b/components/core/src/clp/streaming_compression/lzma/Compressor.hpp index c8c12b9cb..323464545 100644 --- a/components/core/src/clp/streaming_compression/lzma/Compressor.hpp +++ b/components/core/src/clp/streaming_compression/lzma/Compressor.hpp @@ -94,7 +94,7 @@ class Compressor : public ::clp::streaming_compression::Compressor { * Invoke lzma_code() repeatedly with LZMA_RUN until the input is exhausted * * At the end of the workflow, the last bytes of encoded data may still be - * buffered and thus not immediately available at the output block buffer. + * buffered in the LZMA stream and thus not immediately available at the output block buffer. * * Assumes input stream and output block buffer are both in valid states. * @throw `OperationFailed` if LZMA returns an unexpected error value @@ -113,8 +113,8 @@ class Compressor : public ::clp::streaming_compression::Compressor { auto flush_lzma(lzma_action flush_action) -> void; /** - * Flushes the current compressed data in the LZMA output buffer to the - * output file handler. Reset the compression buffer to receive new data. + * Flushes the current compressed data in the output block buffer to the + * output file handler. Reset the output block buffer to receive new data. */ auto flush_stream_output_block_buffer() -> void;