From: Eric Biggers Date: Sat, 14 Jun 2014 04:33:08 +0000 (-0500) Subject: make_canonical_huffman_code(): Stricter validation of max_codeword_len X-Git-Tag: v1.7.0~20 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=757b2d7b9005bd959855428d15e1fb3bf9c1f3fb make_canonical_huffman_code(): Stricter validation of max_codeword_len max_codeword_len must be long enough to give a distinct codeword to each symbol. As we also check that num_syms >= 2, use this check instead of max_codeword_len > 0. --- diff --git a/src/compress_common.c b/src/compress_common.c index 270b8cfe..682a53c5 100644 --- a/src/compress_common.c +++ b/src/compress_common.c @@ -689,7 +689,7 @@ make_canonical_huffman_code(unsigned num_syms, unsigned max_codeword_len, /* Assumptions */ wimlib_assert2(num_syms >= 2); wimlib_assert2(num_syms <= (1 << NUM_SYMBOL_BITS)); - wimlib_assert2(max_codeword_len > 0); + wimlib_assert2((1ULL << max_codeword_len) >= num_syms); wimlib_assert2(max_codeword_len <= 32); /* We begin by sorting the symbols primarily by frequency and