[FFmpeg-devel,1/3] avcodec/mpeg4videodec: Check mb_num also against 0

Submitted by Michael Niedermayer on Jan. 28, 2018, 1:29 a.m.

Details

Message ID 20180128012902.22504-1-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Jan. 28, 2018, 1:29 a.m.
The spec implies that 0 is invalid in addition to the existing checks

Found-by: <kierank>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/mpeg4videodec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 12755b5e8a..ba332de531 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -465,7 +465,7 @@  int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext *ctx)
     }
 
     mb_num = get_bits(&s->gb, mb_num_bits);
-    if (mb_num >= s->mb_num) {
+    if (mb_num >= s->mb_num || !mb_num) {
         av_log(s->avctx, AV_LOG_ERROR,
                "illegal mb_num in video packet (%d %d) \n", mb_num, s->mb_num);
         return -1;