avformat/aviobuf: Stop restricting dynamic buffer sizes to INT_MAX/2

This has originally been done in 568e18b15e
as a precaution against integer overflows, but it is actually easy to
support the full range of int without overflows.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
Andreas Rheinhardt 2020-05-24 04:04:29 +02:00
parent 88d5ae068f
commit fa0bc627c5
1 changed files with 3 additions and 1 deletions

View File

@ -1288,7 +1288,7 @@ static int dyn_buf_write(void *opaque, uint8_t *buf, int buf_size)
/* reallocate buffer if needed */
new_size = (unsigned)d->pos + buf_size;
if (new_size < d->pos || new_size > INT_MAX/2)
if (new_size < d->pos || new_size > INT_MAX)
return -1;
if (new_size > d->allocated_size) {
unsigned new_allocated_size = d->allocated_size ? d->allocated_size
@ -1297,6 +1297,8 @@ static int dyn_buf_write(void *opaque, uint8_t *buf, int buf_size)
while (new_size > new_allocated_size)
new_allocated_size += new_allocated_size / 2 + 1;
new_allocated_size = FFMIN(new_allocated_size, INT_MAX);
if ((err = av_reallocp(&d->buffer, new_allocated_size)) < 0) {
d->allocated_size = 0;
d->size = 0;