aboutsummaryrefslogtreecommitdiff
path: root/src/utils/huffman_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/huffman_utils.c')
-rw-r--r--src/utils/huffman_utils.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/utils/huffman_utils.c b/src/utils/huffman_utils.c
index cf73abd4..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]++;
@@ -267,11 +270,11 @@ int VP8LHuffmanTablesAllocate(int size, HuffmanTables* huffman_tables) {
// Have 'segment' point to the first segment for now, 'root'.
HuffmanTablesSegment* const root = &huffman_tables->root;
huffman_tables->curr_segment = root;
+ root->next = NULL;
// Allocate root.
root->start = (HuffmanCode*)WebPSafeMalloc(size, sizeof(*root->start));
if (root->start == NULL) return 0;
root->curr_table = root->start;
- root->next = NULL;
root->size = size;
return 1;
}