You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
avcodec/webp: Check before allocations
Avoids freeing lateron. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@ -341,6 +341,18 @@ static int read_huffman_code_normal(WebPContext *s, HuffReader *hc,
|
||||
len_counts[len]++;
|
||||
}
|
||||
|
||||
if (get_bits1(&s->gb)) {
|
||||
int bits = 2 + 2 * get_bits(&s->gb, 3);
|
||||
max_symbol = 2 + get_bits(&s->gb, bits);
|
||||
if (max_symbol > alphabet_size) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "max symbol %d > alphabet size %d\n",
|
||||
max_symbol, alphabet_size);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
} else {
|
||||
max_symbol = alphabet_size;
|
||||
}
|
||||
|
||||
ret = huff_reader_build_canonical(&code_len_hc, code_length_code_lengths, len_counts,
|
||||
NUM_CODE_LENGTH_CODES, s->avctx);
|
||||
if (ret < 0)
|
||||
@ -352,19 +364,6 @@ static int read_huffman_code_normal(WebPContext *s, HuffReader *hc,
|
||||
goto finish;
|
||||
}
|
||||
|
||||
if (get_bits1(&s->gb)) {
|
||||
int bits = 2 + 2 * get_bits(&s->gb, 3);
|
||||
max_symbol = 2 + get_bits(&s->gb, bits);
|
||||
if (max_symbol > alphabet_size) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "max symbol %d > alphabet size %d\n",
|
||||
max_symbol, alphabet_size);
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto finish;
|
||||
}
|
||||
} else {
|
||||
max_symbol = alphabet_size;
|
||||
}
|
||||
|
||||
prev_code_len = 8;
|
||||
symbol = 0;
|
||||
memset(len_counts, 0, sizeof(len_counts));
|
||||
|
Reference in New Issue
Block a user