mov_read_stts() accepts stts entries with duration == 0. When such an entry is processed after a prior entry whose duration was clipped to produce drift == 0, the expression 'duration - 1' underflows because duration is 0 and unsigned, producing UINT32_MAX and corrupting the accumulated current_dts for subsequent samples.
Fix: clamp duration to at least 1 before subtracting, matching the existing FFMAX pattern used elsewhere in this function. Signed-off-by: Edson Bruno <[email protected]> --- libavformat/mov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 0c2f592e7f..657c99895c 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3914,7 +3914,7 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (current_dts > corrected_dts) { int64_t drift = av_sat_sub64(current_dts, corrected_dts) / FFMAX(sample_count, 1); - uint32_t correction = (sc->stts_data[i].duration > drift) ? drift : sc->stts_data[i].duration - 1; + uint32_t correction = (duration > drift) ? drift : FFMAX(duration, 1) - 1; current_dts -= correction * (uint64_t)sample_count; sc->stts_data[i].duration -= correction; } -- 2.47.3 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
