diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-03-27 02:52:09 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-03-27 02:52:38 +0400 |
commit | 0d4a66ee7f48c65ac67f4d91c8f8f2bfd47afa0d (patch) | |
tree | bdcc352824c639c40cc26fbda3671233cca128f1 /libavformat | |
parent | 50b68e323c41207a3a69532c89a7675154986c3b (diff) |
avformat/aviobuf: ffio_ensure_seekback: only copy the initialized part of the buffer
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/aviobuf.c | 5 |
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); |