aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-03-26 23:52:09 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-03-26 23:52:38 +0100
commit0d4a66ee7f48c65ac67f4d91c8f8f2bfd47afa0d (patch)
treebdcc352824c639c40cc26fbda3671233cca128f1
parent50b68e323c41207a3a69532c89a7675154986c3b (diff)
downloadffmpeg-0d4a66ee7f48c65ac67f4d91c8f8f2bfd47afa0d.tar.gz
avformat/aviobuf: ffio_ensure_seekback: only copy the initialized part of the buffer
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavformat/aviobuf.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 95fdf200ef..7e1bfcd1eb 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);