From 8d3b044f848dcbf5eecccffdc023263258038867 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 9 Feb 2026 03:07:21 +0100 Subject: [PATCH] avformat/mov: check for duplicate stsd before changing state Signed-off-by: Michael Niedermayer --- libavformat/mov.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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)