mirror of https://git.ffmpeg.org/ffmpeg.git
avformat/aviobuf: ffio_ensure_seekback: only copy the initialized part of the buffer
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
50b68e323c
commit
0d4a66ee7f
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue