From 0b56dedc98cb0367a2c375651ff7820a16bee9cc Mon Sep 17 00:00:00 2001 From: Jonathan Grant Date: Fri, 27 Oct 2023 00:17:27 +0100 Subject: [PATCH] BuildHuffmanTable check sorted[] array bounds before writing Change-Id: I6a83f414e86311121451e9da26004dfc3ac9b21f --- src/utils/huffman_utils.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/utils/huffman_utils.c b/src/utils/huffman_utils.c index 6a791e6a..16f9faaa 100644 --- a/src/utils/huffman_utils.c +++ b/src/utils/huffman_utils.c @@ -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]++;