[FFmpeg-cvslog] avcodec/mjpegdec: Fix leak in case of invalid external Huffman tables

Andreas Rheinhardt git at videolan.org
Sat Apr 3 19:09:45 EEST 2021


ffmpeg | branch: release/4.4 | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sat Apr  3 14:12:44 2021 +0200| [1f3735892bb3aed3684333ae237b680fcf480fca] | committer: Andreas Rheinhardt

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 at niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
(cherry picked from commit 3cc685b7bcc2bcc781b5632bf2e0af6ed941ae27)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1f3735892bb3aed3684333ae237b680fcf480fca
---

 libavcodec/mjpegdec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 20f310fd70..fd6a4eeb76 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -76,6 +76,7 @@ static int init_default_huffman_tables(MJpegDecodeContext *s)
     int i, ret;
 
     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],
                                  ht[i].bits, ht[i].values,
                                  ht[i].class == 1, s->avctx);



More information about the ffmpeg-cvslog mailing list