From 3b47322becc97cfaabd4ffb0561786a0f3e51f26 Mon Sep 17 00:00:00 2001 From: Andrew Sun Date: Thu, 28 Apr 2022 23:20:34 -0400 Subject: [PATCH] preflate: allow decoding of degenerate single-code Huffman codings --- contrib/preflate/support/huffman_helper.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/preflate/support/huffman_helper.cpp b/contrib/preflate/support/huffman_helper.cpp index b3638f5..542979b 100644 --- a/contrib/preflate/support/huffman_helper.cpp +++ b/contrib/preflate/support/huffman_helper.cpp @@ -70,5 +70,6 @@ bool HuffmanHelper::countSymbols( } // Check that we don't have holes - return nextCode[maxLength] + blCount[maxLength] == (unsigned)(1 << (maxLength - 1)); + unsigned codeCheck = nextCode[maxLength] + blCount[maxLength]; + return codeCheck == (unsigned)(1 << (maxLength - 1)) || codeCheck == 1 && maxLength == 2; }