PR #23520 opened by michaelni
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23520
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23520.patch

Fixes: NULL pointer dereference

As a sideeffect this also sets the timescale correctly if an
intermediate matches MOV_TIMESCALE_Q, the previous code stoped
in that case as it could not distinguish it from the overflow detection

Regression since: 51f5f60443

Signed-off-by: Michael Niedermayer <[email protected]>

# Summary of changes

Briefly describe what this PR does and why.

<!--
If this PR requires new FATE test samples, attach them to the PR and
list their target paths below (relative to the fate-suite root).

Attached filenames must match the sample's filename:

```fate-samples
# e.g. vorbis/new-sample.ogg
```
-->



>From 33645879cd9eac152f93e7bea8290b09cce94213 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Wed, 17 Jun 2026 21:11:26 +0200
Subject: [PATCH] avformat/movenc: initialize all tracks

Fixes: NULL pointer dereference

As a sideeffect this also sets the timescale correctly if an
intermediate matches MOV_TIMESCALE_Q, the previous code stoped
in that case as it could not distinguish it from the overflow detection

Regression since: 51f5f60443

Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavformat/movenc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 7690819232..7c9dbb29f7 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -8429,10 +8429,11 @@ static int mov_init(AVFormatContext *s)
             track->par = st->codecpar;
         }
 
-        movie_timescale = av_gcd_q(movie_timescale, st->time_base, INT_MAX, 
MOV_TIMESCALE_Q);
-        if (!av_cmp_q(movie_timescale, MOV_TIMESCALE_Q))
-            break;
+        movie_timescale = av_gcd_q(movie_timescale, st->time_base, INT_MAX, 
(AVRational){1,0});
     }
+    if (!movie_timescale.den)
+        movie_timescale = MOV_TIMESCALE_Q;
+
     if (!mov->movie_timescale)
         mov->movie_timescale = FFMAX(movie_timescale.den, MOV_TIMESCALE);
 
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to