[FFmpeg-devel] [PATCH 2/3] avformat/aviobuf: fix checks in ffio_ensure_seekback

Marton Balint cus at passwd.hu
Sun Sep 20 11:52:52 EEST 2020


Signed-off-by: Marton Balint <cus at passwd.hu>
---
 libavformat/aviobuf.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 9675425349..aa1d6c0830 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -999,9 +999,12 @@ 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;
 
-    buf_size += s->buf_ptr - s->buffer + max_buffer_size;
+    if (buf_size <= s->buf_end - s->buf_ptr)
+        return 0;
+
+    buf_size += s->buf_ptr - s->buffer + max_buffer_size - 1;
 
-    if (buf_size < filled || s->seekable || !s->read_packet)
+    if (buf_size <= s->buffer_size || s->seekable || !s->read_packet)
         return 0;
     av_assert0(!s->write_flag);
 
-- 
2.26.2



More information about the ffmpeg-devel mailing list