[FFmpeg-devel] [PATCH 7/7] avcodec/cbs_mpeg2: Treat slices without data as invalid

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Tue Dec 10 00:26:04 EET 2019


They are spec-incompliant.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
 libavcodec/cbs_mpeg2.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c
index e42c602476..b57551c92a 100644
--- a/libavcodec/cbs_mpeg2.c
+++ b/libavcodec/cbs_mpeg2.c
@@ -245,6 +245,9 @@ static int cbs_mpeg2_read_unit(CodedBitstreamContext *ctx,
         if (err < 0)
             return err;
 
+        if (!get_bits_left(&gbc))
+            return AVERROR_INVALIDDATA;
+
         pos = get_bits_count(&gbc);
         len = unit->data_size;
 
-- 
2.20.1



More information about the ffmpeg-devel mailing list