avformat/mov: Check default_encrypted_sample before use in mov_read_sample_encryption...
authorMichael Niedermayer <michael@niedermayer.cc>
Sat, 21 Jul 2018 15:20:44 +0000 (17:20 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 26 Jul 2018 00:42:42 +0000 (02:42 +0200)
Fixes: 2018-0721-sample
Fixes: null pointer dereference

Found-by: Nikita Knyzhov (knnikita@yandex.ru)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/mov.c

index 870c603..82cd410 100644 (file)
@@ -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);