[FFmpeg-cvslog] avformat/aviobuf: ffio_ensure_seekback: only copy the initialized part of the buffer

Michael Niedermayer git at videolan.org
Thu Mar 27 01:09:13 CET 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Mar 26 23:52:09 2014 +0100| [0d4a66ee7f48c65ac67f4d91c8f8f2bfd47afa0d] | committer: Michael Niedermayer

avformat/aviobuf: ffio_ensure_seekback: only copy the initialized part of the buffer

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavformat/aviobuf.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 95fdf20..7e1bfcd 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -762,10 +762,11 @@ int ffio_ensure_seekback(AVIOContext *s, int buf_size)
     uint8_t *buffer;
     int max_buffer_size = s->max_packet_size ?
                           s->max_packet_size : IO_BUFFER_SIZE;
+    int filled = s->buf_end - s->buffer;
 
     buf_size += s->buf_ptr - s->buffer + max_buffer_size;
 
-    if (buf_size < s->buffer_size || s->seekable)
+    if (buf_size < filled || s->seekable)
         return 0;
     av_assert0(!s->write_flag);
 
@@ -773,7 +774,7 @@ int ffio_ensure_seekback(AVIOContext *s, int buf_size)
     if (!buffer)
         return AVERROR(ENOMEM);
 
-    memcpy(buffer, s->buffer, s->buffer_size);
+    memcpy(buffer, s->buffer, filled);
     av_free(s->buffer);
     s->buf_ptr = buffer + (s->buf_ptr - s->buffer);
     s->buf_end = buffer + (s->buf_end - s->buffer);



More information about the ffmpeg-cvslog mailing list