]> wimlib.net Git - wimlib/commitdiff
lzx_compress.c: chosen_sequences[] length was 1 too short
authorEric Biggers <ebiggers3@gmail.com>
Mon, 19 Oct 2015 00:39:23 +0000 (19:39 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Mon, 19 Oct 2015 00:39:23 +0000 (19:39 -0500)
A block could have all length 2 matches (highly unlikely).

src/lzx_compress.c

index cc43fd6cc79ddf07eab9b067589a531e08b1c9a1..ec90ba1640cc0a11f18b1b848e5dfee28e915356 100644 (file)
@@ -410,8 +410,10 @@ struct lzx_compressor {
 
        /* The matches and literals that the parser has chosen for the current
         * block.  The required length of this array is limited by the maximum
 
        /* The matches and literals that the parser has chosen for the current
         * block.  The required length of this array is limited by the maximum
-        * number of matches that can ever be chosen for a single block.  */
-       struct lzx_sequence chosen_sequences[DIV_ROUND_UP(LZX_DIV_BLOCK_SIZE, LZX_MIN_MATCH_LEN)];
+        * number of matches that can ever be chosen for a single block, plus
+        * one for the special entry at the end.  */
+       struct lzx_sequence chosen_sequences[
+                      DIV_ROUND_UP(LZX_DIV_BLOCK_SIZE, LZX_MIN_MATCH_LEN) + 1];
 
        /* Tables for mapping adjusted offsets to offset slots  */
 
 
        /* Tables for mapping adjusted offsets to offset slots  */