]> wimlib.net Git - wimlib/blobdiff - src/lzx_decompress.c
decompress_common.h: make bitstream_read_bytes() fill buffer itself
[wimlib] / src / lzx_decompress.c
index 1ebaf3519c8ec8dc169aa46c0737a34f6d06f71b..d9ab5c3328b2366c731c80a16033be8f76383267 100644 (file)
@@ -583,17 +583,15 @@ lzx_decompress(const void *compressed_data, size_t compressed_size,
                         * have been encoded as a literal using mainsym 0xe8. */
                        if (dec->tables.maincode_lens[0xe8] != 0)
                                may_have_e8_byte = true;
                         * have been encoded as a literal using mainsym 0xe8. */
                        if (dec->tables.maincode_lens[0xe8] != 0)
                                may_have_e8_byte = true;
+
+                       out_next += block_size;
                } else {
 
                        /* Uncompressed block.  */
                } else {
 
                        /* Uncompressed block.  */
-                       const u8 *p;
-
-                       p = bitstream_read_bytes(&istream, block_size);
-                       if (!p)
+                       out_next = bitstream_read_bytes(&istream, out_next, block_size);
+                       if (!out_next)
                                return -1;
 
                                return -1;
 
-                       memcpy(out_next, p, block_size);
-
                        /* Re-align the bitstream if an odd number of bytes was
                         * read.  */
                        if (block_size & 1)
                        /* Re-align the bitstream if an odd number of bytes was
                         * read.  */
                        if (block_size & 1)
@@ -601,8 +599,6 @@ lzx_decompress(const void *compressed_data, size_t compressed_size,
 
                        may_have_e8_byte = true;
                }
 
                        may_have_e8_byte = true;
                }
-
-               out_next += block_size;
        }
 
        /* Postprocess the data unless it cannot possibly contain 0xe8 bytes  */
        }
 
        /* Postprocess the data unless it cannot possibly contain 0xe8 bytes  */