[FFmpeg-devel,2/3] mpeg12dec: validate color primaries

Submitted by Andreas Cadhalpun on Dec. 22, 2016, 11:58 p.m.

Details

Message ID f23b2819-4c42-4539-1a2c-b1685726a7ae@googlemail.com
State New
Headers show

Commit Message

Andreas Cadhalpun Dec. 22, 2016, 11:58 p.m.
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
---
 libavcodec/mpeg12dec.c | 4 ++++
 1 file changed, 4 insertions(+)

Patch hide | download patch | download mbox

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index d3dc67ad6a..89aecd4de4 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1468,6 +1468,10 @@  static void mpeg_decode_sequence_display_extension(Mpeg1Context *s1)
     color_description = get_bits1(&s->gb);
     if (color_description) {
         s->avctx->color_primaries = get_bits(&s->gb, 8);
+        if (!av_color_primaries_name(s->avctx->color_primaries)) {
+            av_log(s->avctx, AV_LOG_WARNING, "Invalid color primaries %d, setting to unspecified\n", s->avctx->color_primaries);
+            s->avctx->color_primaries = AVCOL_PRI_UNSPECIFIED;
+        }
         s->avctx->color_trc       = get_bits(&s->gb, 8);
         s->avctx->colorspace      = get_bits(&s->gb, 8);
         if (!av_color_space_name(s->avctx->colorspace)) {