[FFmpeg-cvslog] avfilter/f_reverse: Apply PTS compensation only when pts is available

Michael Niedermayer git at videolan.org
Sun Apr 14 19:34:55 EEST 2024


ffmpeg | branch: release/6.0 | Michael Niedermayer <michael at niedermayer.cc> | Sat Dec 23 18:04:32 2023 +0100| [302af6f9a7d783ab760ce6a09345dc193e39d56b] | committer: Michael Niedermayer

avfilter/f_reverse: Apply PTS compensation only when pts is available

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>
(cherry picked from commit 61e73851a33f0b4cb7662f8578a4695e77bd3c19)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=302af6f9a7d783ab760ce6a09345dc193e39d56b
---

 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 0ab2a3ab29..56d433768b 100644
--- a/libavfilter/f_reverse.c
+++ b/libavfilter/f_reverse.c
@@ -269,7 +269,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);



More information about the ffmpeg-cvslog mailing list