diff mbox series

[FFmpeg-devel,v2,041/162] avcodec/motionpixels: Be more strict when parsing Huffman trees

Message ID 20201120072116.818090-42-andreas.rheinhardt@gmail.com
State Accepted
Headers show
Series VLC, esp. init_vlc patches
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Nov. 20, 2020, 7:19 a.m. UTC
This ensures that the number of leafs in the Huffman tree equals the
number it is supposed to be and therefore ensures that the VLC tree is
complete, allowing us to remove checks.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
An alternative would be to use current_codes_count to initialize the
VLC.

 libavcodec/motionpixels.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c
index 0bf153f883..4b9830fbed 100644
--- a/libavcodec/motionpixels.c
+++ b/libavcodec/motionpixels.c
@@ -133,7 +133,7 @@  static int mp_get_code(MotionPixelsContext *mp, GetBitContext *gb, int size, int
         if (mp_get_code(mp, gb, size, code + 1) < 0)
             return AVERROR_INVALIDDATA;
     }
-    if (mp->current_codes_count >= MAX_HUFF_CODES) {
+    if (mp->current_codes_count >= mp->codes_count) {
         av_log(mp->avctx, AV_LOG_ERROR, "too many codes\n");
         return AVERROR_INVALIDDATA;
     }