Huffman compression: handle QByteArray's elements as unsigned char

Fixes: QTBUG-86418
Pick-to: 5.15
Change-Id: Ie57ecad2b1fda7c2fc0de60cbdb4304c00e645d0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Timur Pocheptsov 2020-09-07 10:21:58 +02:00
parent fec51be209
commit 3e210dc19a

View File

@ -392,8 +392,10 @@ quint64 huffman_encoded_bit_length(const QByteArray &inputData)
void huffman_encode_string(const QByteArray &inputData, BitOStream &outputStream)
{
for (int i = 0, e = inputData.size(); i < e; ++i)
write_huffman_code(outputStream, staticHuffmanCodeTable[int(inputData[i])]);
for (int i = 0, e = inputData.size(); i < e; ++i) {
const auto value = uchar(inputData[i]);
write_huffman_code(outputStream, staticHuffmanCodeTable[value]);
}
// Pad bits ...
if (outputStream.bitLength() % 8)