This is an automated email from the git hooks/post-receive script.
Git pushed a commit to branch master
in repository ffmpeg.
The following commit(s) were added to refs/heads/master by this push:
new 005e963c85 Guard against int overflow when discarding samples
005e963c85 is described below
commit 005e963c85689f4714ea9948a6be4739fc68ebc9
Author: Thomas Guilbert <[email protected]>
AuthorDate: Wed Jun 17 03:18:51 2026 +0000
Commit: michaelni <[email protected]>
CommitDate: Wed Jul 15 01:36:36 2026 +0000
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.
---
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]