1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-28 20:53:54 +02:00

avcodec/mjpegdec: Fix leak in case of invalid external Huffman tables

When using external Huffman tables fails during init, the decoder
reverts back to using the default Huffman tables; and when doing so,
the current VLC tables leak because init_default_huffman_tables()
doesn't free them before overwriting them.

Sample:
samples.ffmpeg.org/archive/all/avi+mjpeg+pcm_s16le++mjpeg-interlace.avi

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 3cc685b7bc)
This commit is contained in:
Andreas Rheinhardt 2021-04-03 14:12:44 +02:00
parent edbc26e38b
commit 1f3735892b

View File

@ -76,6 +76,7 @@ static int init_default_huffman_tables(MJpegDecodeContext *s)
int i, ret; int i, ret;
for (i = 0; i < FF_ARRAY_ELEMS(ht); i++) { for (i = 0; i < FF_ARRAY_ELEMS(ht); i++) {
ff_free_vlc(&s->vlcs[ht[i].class][ht[i].index]);
ret = ff_mjpeg_build_vlc(&s->vlcs[ht[i].class][ht[i].index], ret = ff_mjpeg_build_vlc(&s->vlcs[ht[i].class][ht[i].index],
ht[i].bits, ht[i].values, ht[i].bits, ht[i].values,
ht[i].class == 1, s->avctx); ht[i].class == 1, s->avctx);