BuildHuffmanTable check sorted[] array bounds before writing

Change-Id: I6a83f414e86311121451e9da26004dfc3ac9b21f
This commit is contained in:
Jonathan Grant 2023-10-27 00:17:27 +01:00
parent a429c0de64
commit 0b56dedc98

View File

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