Commit e5031bd8b4 for ffmpeg
commit e5031bd8b401d5fe1d731f186288ee34a26de61f
Author: Kacper Michajłow <kasper93@gmail.com>
Date: Fri Dec 4 22:57:51 2026 +0100
avformat/mov: saturate the end of the last sample of an edit
Fixes: signed integer overflow: 4608 + 9223372036854775000 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 8257e980f1..3e825a82b7 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4972,11 +4972,11 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
// Only start incrementing DTS in frame_duration amounts, when we encounter a frame in edit list.
if (edit_list_start_encountered > 0) {
- edit_list_dts_counter = edit_list_dts_counter + frame_duration;
+ edit_list_dts_counter = av_sat_add64(edit_list_dts_counter, frame_duration);
}
// Break when found first key frame after edit entry completion
- if ((curr_cts + frame_duration >= (edit_list_duration + edit_list_media_time)) &&
+ if ((av_sat_add64(curr_cts, frame_duration) >= (edit_list_duration + edit_list_media_time)) &&
((flags & AVINDEX_KEYFRAME) || ((st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)))) {
if (msc->ctts_count) {
// If we have CTTS and this is the first keyframe after edit elist,