From: Eric Biggers Date: Mon, 19 Oct 2015 00:39:14 +0000 (-0500) Subject: lzx_compress.c: CAN_BUFFER() was 1 off X-Git-Tag: v1.8.3~59 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=2eb82c7acfce21c84061366679f014ebe5d93c56;hp=53588a19dc7176736cf1791b75584314cab3d8f2 lzx_compress.c: CAN_BUFFER() was 1 off --- 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);