[FFmpeg-cvslog] avformat/aviobuf: check if requested seekback buffer is already read

Marton Balint git at videolan.org
Fri Oct 9 22:25:16 EEST 2020


ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Sat Sep 26 19:20:50 2020 +0200| [6d972beb23385022319cb36892519c70b0d0fc22] | committer: Marton Balint

avformat/aviobuf: check if requested seekback buffer is already read

Existing code did not check if the requested seekback buffer is
already read entirely. In this case, nothing has to be done to guarantee
seekback.

Signed-off-by: Marton Balint <cus at passwd.hu>

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

 libavformat/aviobuf.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 9675425349..d94be478ac 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -999,6 +999,9 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
     int filled = s->buf_end - s->buffer;
     ptrdiff_t checksum_ptr_offset = s->checksum_ptr ? s->checksum_ptr - s->buffer : -1;
 
+    if (buf_size <= s->buf_end - s->buf_ptr)
+        return 0;
+
     buf_size += s->buf_ptr - s->buffer + max_buffer_size;
 
     if (buf_size < filled || s->seekable || !s->read_packet)



More information about the ffmpeg-cvslog mailing list