1 gst-ffmpeg: avcodec/parser: reset indexes on realloc failure
5 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
6 (cherry picked from commit f31011e9abfb2ae75bb32bc44e2c34194c8dc40a)
8 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
10 Upstream-Status: Backport
12 Signed-off-by: Yue Tao <yue.tao@windriver.com>
15 libavcodec/parser.c | 10 +++++++---
16 1 files changed, 7 insertions(+), 3 deletions(-)
18 diff --git a/libavcodec/parser.c b/libavcodec/parser.c
19 index 2c6de6e..66eca06 100644
20 --- a/gst-libs/ext/libav/libavcodec/parser.c
21 +++ b/gst-libs/ext/libav/libavcodec/parser.c
22 @@ -241,8 +241,10 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s
23 if(next == END_NOT_FOUND){
24 void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
29 return AVERROR(ENOMEM);
31 pc->buffer = new_buffer;
32 memcpy(&pc->buffer[pc->index], *buf, *buf_size);
33 pc->index += *buf_size;
34 @@ -255,9 +257,11 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s
35 /* append to buffer */
37 void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
41 + pc->overread_index =
43 return AVERROR(ENOMEM);
45 pc->buffer = new_buffer;
46 if (next > -FF_INPUT_BUFFER_PADDING_SIZE)
47 memcpy(&pc->buffer[pc->index], *buf,