Commit 9911777cc6 for ffmpeg
commit 9911777cc6d8d7d189a29cb362ca82edcc4c1107
Author: Kacper Michajłow <kasper93@gmail.com>
Date: Sat Dec 5 01:24:48 2026 +0100
avformat/mov: saturate the duration of the edit list
Fixes: signed integer overflow: 9223372036854775807 - -512 cannot be represented in type 'long int'
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 3e825a82b7..c79caaa047 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -5020,7 +5020,8 @@ truncated:
st->start_time = empty_edits_sum_duration;
// Update av stream length, if it ends up shorter than the track's media duration
- st->duration = FFMIN(st->duration, edit_list_dts_entry_end - start_dts);
+ int64_t edits_duration = av_sat_sub64(edit_list_dts_entry_end, start_dts);
+ st->duration = FFMIN(st->duration, edits_duration);
// The skipped samples are counted in the track's clock. With explicit SBR
// signalling, HE-AAC often keeps it at the core rate, half the output
// rate. A sample rate below the clock may be the core rate of implicit