[FFmpeg-devel] [PATCH 2/2] avfilter/f_reverse: Apply PTS compensation only when pts is available
Michael Niedermayer
michael at niedermayer.cc
Sun Dec 24 03:49:49 EET 2023
Fixes: out of array access
Fixes: tickets/10753/poc16ffmpeg
Regression since: 45dc668aea0edac34969b5a1ff76cf9ad3a09be1
Found-by: Zeng Yunxiang
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
libavfilter/f_reverse.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libavfilter/f_reverse.c b/libavfilter/f_reverse.c
index 086819a207e..744f4a3cc83 100644
--- a/libavfilter/f_reverse.c
+++ b/libavfilter/f_reverse.c
@@ -266,7 +266,8 @@ static int areverse_request_frame(AVFilterLink *outlink)
AVFrame *out = s->frames[s->nb_frames - 1];
out->duration = s->duration[s->flush_idx];
out->pts = s->pts[s->flush_idx++] - s->nb_samples;
- s->nb_samples += s->pts[s->flush_idx] - s->pts[s->flush_idx - 1] - out->nb_samples;
+ if (s->nb_frames > 1)
+ s->nb_samples += s->pts[s->flush_idx] - s->pts[s->flush_idx - 1] - out->nb_samples;
if (av_sample_fmt_is_planar(out->format))
reverse_samples_planar(out);
--
2.17.1
More information about the ffmpeg-devel
mailing list