From 757b2d7b9005bd959855428d15e1fb3bf9c1f3fb Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Fri, 13 Jun 2014 23:33:08 -0500 Subject: [PATCH] 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. --- src/compress_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- 2.43.0