[FFmpeg-devel] [PATCH 2/3] mpeg12dec: validate color primaries
Andreas Cadhalpun
andreas.cadhalpun at googlemail.com
Fri Dec 23 01:58:20 EET 2016
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
---
libavcodec/mpeg12dec.c | 4 ++++
1 file changed, 4 insertions(+)
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)) {
--
2.11.0
More information about the ffmpeg-devel
mailing list