aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-09-26 21:03:48 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-10-03 01:04:19 +0200
commit95e26d33d76d00b3684485e623cb10644820870f (patch)
treea74af80b4671bb2fd959bc9c69bea7f5d757001b /libavcodec
parentf32051cd733dde7ab95079e6e05a1c44a4d797eb (diff)
downloadffmpeg-95e26d33d76d00b3684485e623cb10644820870f.tar.gz
avcodec/parser: reset indexes on realloc failure
Fixes Ticket2982 Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit f31011e9abfb2ae75bb32bc44e2c34194c8dc40a) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/parser.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libavcodec/parser.c b/libavcodec/parser.c
index f7cb5cfa67..c30b43e0e5 100644
--- a/libavcodec/parser.c
+++ b/libavcodec/parser.c
@@ -235,8 +235,10 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s
if(next == END_NOT_FOUND){
void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
- if(!new_buffer)
+ if(!new_buffer) {
+ pc->index = 0;
return AVERROR(ENOMEM);
+ }
pc->buffer = new_buffer;
memcpy(&pc->buffer[pc->index], *buf, *buf_size);
pc->index += *buf_size;
@@ -249,9 +251,11 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s
/* append to buffer */
if(pc->index){
void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
-
- if(!new_buffer)
+ if(!new_buffer) {
+ pc->overread_index =
+ pc->index = 0;
return AVERROR(ENOMEM);
+ }
pc->buffer = new_buffer;
if (next > -FF_INPUT_BUFFER_PADDING_SIZE)
memcpy(&pc->buffer[pc->index], *buf,