diff --git a/libavformat/mov.c b/libavformat/mov.c index 396a559fa4..64e943f73e 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3209,6 +3209,12 @@ static int mov_read_stsd(MOVContext *c, AVIOContext *pb, MOVAtom atom) st = c->fc->streams[c->fc->nb_streams - 1]; sc = st->priv_data; + if (sc->extradata) { + av_log(c->fc, AV_LOG_ERROR, + "Duplicate stsd found in this track.\n"); + return AVERROR_INVALIDDATA; + } + sc->stsd_version = avio_r8(pb); avio_rb24(pb); /* flags */ entries = avio_rb32(pb); @@ -3219,12 +3225,6 @@ static int mov_read_stsd(MOVContext *c, AVIOContext *pb, MOVAtom atom) return AVERROR_INVALIDDATA; } - if (sc->extradata) { - av_log(c->fc, AV_LOG_ERROR, - "Duplicate stsd found in this track.\n"); - return AVERROR_INVALIDDATA; - } - /* Prepare space for hosting multiple extradata. */ sc->extradata = av_calloc(entries, sizeof(*sc->extradata)); if (!sc->extradata)