diff mbox

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

Message ID 20191209222604.28920-7-andreas.rheinhardt@gmail.com
State New
Headers show

Commit Message

Andreas Rheinhardt Dec. 9, 2019, 10:26 p.m. UTC
They are spec-incompliant.

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

Patch

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;