Fix a bug in lzma_block_buffer_decode(), although this
authorLasse Collin <lasse.collin@tukaani.org>
Sun, 1 Feb 2009 20:40:35 +0000 (22:40 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Sun, 1 Feb 2009 20:40:35 +0000 (22:40 +0200)
function should be rewritten anyway.

src/liblzma/common/block_buffer_decoder.c

index ec24e44..9f95637 100644 (file)
@@ -50,10 +50,6 @@ lzma_block_buffer_decode(lzma_block *block, lzma_allocator *allocator,
                if (ret == LZMA_STREAM_END) {
                        ret = LZMA_OK;
                } else {
-                       // Something went wrong, restore the positions.
-                       *in_pos = in_start;
-                       *out_pos = out_start;
-
                        if (ret == LZMA_OK) {
                                // Either the input was truncated or the
                                // output buffer was too small.
@@ -75,6 +71,10 @@ lzma_block_buffer_decode(lzma_block *block, lzma_allocator *allocator,
                                else
                                        ret = LZMA_BUF_ERROR;
                        }
+
+                       // Restore the positions.
+                       *in_pos = in_start;
+                       *out_pos = out_start;
                }
        }