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 <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2018-07-21 17:20:44 +02:00
parent 8b710ea5e7
commit a37c620269
1 changed files with 5 additions and 0 deletions

View 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);