]> granicus.if.org Git - xz/commitdiff
Fix data corruption in LZMA encoder. Note that this bug was
authorLasse Collin <lasse.collin@tukaani.org>
Fri, 14 Mar 2008 21:16:11 +0000 (23:16 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Fri, 14 Mar 2008 21:16:11 +0000 (23:16 +0200)
specific to liblzma and was *not* present in LZMA SDK.

src/liblzma/lzma/lzma_encoder.c

index 0fcb755c32cb7889c247ac88964c54bc46f93665..01c823ca38fabb64e447a778efbacbf243e6c71c 100644 (file)
@@ -157,6 +157,10 @@ lzma_lzma_encode(lzma_coder *coder, uint8_t *restrict out,
        // Initialize the stream if no data has been encoded yet.
        if (!coder->is_initialized) {
                if (coder->lz.read_pos == coder->lz.read_limit) {
+                       if (coder->lz.sequence == SEQ_RUN)
+                               return false; // We cannot do anything.
+
+                       // We are finishing (we cannot get here when flushing).
                        assert(coder->lz.write_pos == coder->lz.read_pos);
                        assert(coder->lz.sequence == SEQ_FINISH);
                } else {