From 2eb82c7acfce21c84061366679f014ebe5d93c56 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sun, 18 Oct 2015 19:39:14 -0500 Subject: [PATCH] lzx_compress.c: CAN_BUFFER() was 1 off --- src/lzx_compress.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lzx_compress.c b/src/lzx_compress.c index ca9906e7..cc43fd6c 100644 --- a/src/lzx_compress.c +++ b/src/lzx_compress.c @@ -548,7 +548,7 @@ struct lzx_output_bitstream { /* Can the specified number of bits always be added to 'bitbuf' after any * pending 16-bit coding units have been flushed? */ -#define CAN_BUFFER(n) ((n) <= (8 * sizeof(machine_word_t)) - 16) +#define CAN_BUFFER(n) ((n) <= (8 * sizeof(machine_word_t)) - 15) /* * Initialize the output bitstream. @@ -994,6 +994,8 @@ lzx_write_sequences(struct lzx_output_bitstream *os, int block_type, if (!CAN_BUFFER(MAX_MATCH_BITS)) lzx_flush_bits(os, ALIGNED_CODEWORD_LIMIT); } else { + STATIC_ASSERT(CAN_BUFFER(17)); + lzx_add_bits(os, extra_bits, num_extra_bits); if (!CAN_BUFFER(MAX_MATCH_BITS)) lzx_flush_bits(os, 17); -- 2.43.0