From 8d91746c5772779e0e0593112c0143284452ee6e Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sun, 18 Oct 2015 19:39:23 -0500 Subject: [PATCH] lzx_compress.c: chosen_sequences[] length was 1 too short A block could have all length 2 matches (highly unlikely). --- src/lzx_compress.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lzx_compress.c b/src/lzx_compress.c index cc43fd6c..ec90ba16 100644 --- a/src/lzx_compress.c +++ b/src/lzx_compress.c @@ -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 - * 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 */ -- 2.43.0