Fix a bug in ReadHuffmanCode().
diff --git a/dec/huffman.c b/dec/huffman.c
index c68a404..2407670 100644
--- a/dec/huffman.c
+++ b/dec/huffman.c
@@ -88,6 +88,7 @@
offset[bits] = symbol;
bits++;
});
+ /* Symbols with code length 0 are placed after all other symbols. */
offset[0] = 17;
/* sort symbols by length, by symbol order within each length */
@@ -101,8 +102,8 @@
table_size = 1 << BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH;
- /* special case code with only one value */
- if (offset[BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH] == 0) {
+ /* Special case: all symbols but one have 0 code length. */
+ if (offset[0] == 0) {
code.bits = 0;
code.value = (uint16_t)sorted[0];
for (key = 0; key < table_size; ++key) {