This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch release/9.0 in repository ffmpeg.
commit 3b92cd5fa9718e2c3912d2bf58945b14d819023c Author: Thomas Guilbert <[email protected]> AuthorDate: Wed Jun 17 03:18:51 2026 +0000 Commit: Michael Niedermayer <[email protected]> CommitDate: Tue Jul 21 23:00:00 2026 +0200 Guard against int overflow when discarding samples In `discard_samples()`, the rescaling operation can evaluate to AV_NOPTS_VALUE if the rescaling operation overflows. This commit prevents adjusting timestamp and durations by the invalid value. (cherry picked from commit 005e963c85689f4714ea9948a6be4739fc68ebc9) Signed-off-by: Michael Niedermayer <[email protected]> --- libavcodec/decode.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 6f85e5f514..ba6ff8a9fd 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -374,12 +374,18 @@ static int discard_samples(AVCodecContext *avctx, AVFrame *frame, int64_t *disca int64_t diff_ts = av_rescale_q(avci->skip_samples, (AVRational){1, avctx->sample_rate}, avctx->pkt_timebase); - if (frame->pts != AV_NOPTS_VALUE) - frame->pts += diff_ts; - if (frame->pkt_dts != AV_NOPTS_VALUE) - frame->pkt_dts += diff_ts; - if (frame->duration >= diff_ts) - frame->duration -= diff_ts; + if (diff_ts != AV_NOPTS_VALUE) { + if (frame->pts != AV_NOPTS_VALUE) + frame->pts = av_sat_add64(frame->pts, diff_ts); + if (frame->pkt_dts != AV_NOPTS_VALUE) + frame->pkt_dts = av_sat_add64(frame->pkt_dts, diff_ts); + if (frame->duration >= diff_ts) + frame->duration = av_sat_sub64(frame->duration, diff_ts); + } else { + frame->pts = AV_NOPTS_VALUE; + frame->pkt_dts = AV_NOPTS_VALUE; + frame->duration = 0; + } } else av_log(avctx, AV_LOG_WARNING, "Could not update timestamps for skipped samples.\n"); @@ -400,7 +406,7 @@ static int discard_samples(AVCodecContext *avctx, AVFrame *frame, int64_t *disca int64_t diff_ts = av_rescale_q(frame->nb_samples - discard_padding, (AVRational){1, avctx->sample_rate}, avctx->pkt_timebase); - frame->duration = diff_ts; + frame->duration = diff_ts == AV_NOPTS_VALUE ? 0 : diff_ts; } else av_log(avctx, AV_LOG_WARNING, "Could not update timestamps for discarded samples.\n"); _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
