Merge "BuildHuffmanTable check sorted[] array bounds before writing" into main

This commit is contained in:
Vincent Rabaud 2023-11-22 15:45:18 +00:00 committed by Gerrit Code Review
commit 89c5b91746

View File

@ -122,6 +122,9 @@ static int BuildHuffmanTable(HuffmanCode* const root_table, int root_bits,
const int symbol_code_length = code_lengths[symbol]; const int symbol_code_length = code_lengths[symbol];
if (code_lengths[symbol] > 0) { if (code_lengths[symbol] > 0) {
if (sorted != NULL) { if (sorted != NULL) {
if(offset[symbol_code_length] >= code_lengths_size) {
return 0;
}
sorted[offset[symbol_code_length]++] = symbol; sorted[offset[symbol_code_length]++] = symbol;
} else { } else {
offset[symbol_code_length]++; offset[symbol_code_length]++;