avformat/mov: fix crash when stsz_sample_size is zero and sample_sizes is null
authorZhao Zhili <zhilizhao@tencent.com>
Tue, 25 Nov 2025 05:00:34 +0000 (13:00 +0800)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 18 Jun 2026 18:32:38 +0000 (20:32 +0200)
Co-Authored-by: James Almer <jamrial@gmail.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
(cherry picked from commit cac5018eb9278263e76ccc2891509ed662474853)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 55da57f72377d4d6de5b80655614fc0161c0a0b0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/mov.c

index 51726874060ea8478ff0e0e09baed51868f5451d..90cc8b523bbf86575531640ba5b758cc452ef2aa 100644 (file)
@@ -5033,7 +5033,8 @@ static int sanity_checks(void *log_obj, MOVStreamContext *sc, int index)
 {
     if ((sc->chunk_count && (!sc->stts_count || !sc->stsc_count ||
                             (!sc->sample_size && !sc->sample_count))) ||
-        (!sc->chunk_count && sc->sample_count)) {
+        (sc->sample_count && (!sc->chunk_count ||
+                             (!sc->sample_size && !sc->sample_sizes)))) {
         av_log(log_obj, AV_LOG_ERROR, "stream %d, missing mandatory atoms, broken header\n",
                index);
         return 1;