From a37c62026991853a17ce9e19ff0cf39b2a2b1974 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 21 Jul 2018 17:20:44 +0200 Subject: [PATCH] avformat/mov: Check default_encrypted_sample before use in mov_read_sample_encryption_info() Fixes: 2018-0721-sample Fixes: null pointer dereference Found-by: Nikita Knyzhov (knnikita@yandex.ru) Signed-off-by: Michael Niedermayer --- libavformat/mov.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index 870c603f0b..82cd410a72 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -5876,6 +5876,11 @@ static int mov_read_sample_encryption_info(MOVContext *c, AVIOContext *pb, MOVSt unsigned int subsample_count; AVSubsampleEncryptionInfo *subsamples; + if (!sc->cenc.default_encrypted_sample) { + av_log(c->fc, AV_LOG_ERROR, "Missing schm or tenc\n"); + return AVERROR_INVALIDDATA; + } + *sample = av_encryption_info_clone(sc->cenc.default_encrypted_sample); if (!*sample) return AVERROR(ENOMEM);