diff options
author | Martin Storsjö <martin@martin.st> | 2013-09-26 17:37:02 +0400 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2013-09-27 00:14:03 +0400 |
commit | d872fb0f7ff2ff0ba87f5ccf6a1a55ca2be472c9 (patch) | |
tree | 92ef865da60624c41be1e58c505c95508662ad7d /libavformat/aviobuf.c | |
parent | 06ebc0bf9a6401733a4ce1310325de19f631819a (diff) |
lavf: Reset the entry count and allocation size variables on av_reallocp failures
When av_reallocp fails, the associated variables that keep track of
the number of elements in the array (and in some cases, the
separate number of allocated elements) need to be reset.
Not all of these might technically be needed, but it's better to
reset them if in doubt, to make sure variables don't end up
conflicting.
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/aviobuf.c')
-rw-r--r-- | libavformat/aviobuf.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 3f27d6976c..5064eb826b 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -880,8 +880,11 @@ static int dyn_buf_write(void *opaque, uint8_t *buf, int buf_size) if (new_allocated_size > d->allocated_size) { int err; - if ((err = av_reallocp(&d->buffer, new_allocated_size)) < 0) + if ((err = av_reallocp(&d->buffer, new_allocated_size)) < 0) { + d->allocated_size = 0; + d->size = 0; return err; + } d->allocated_size = new_allocated_size; } memcpy(d->buffer + d->pos, buf, buf_size); |