]> git.sesse.net Git - ffmpeg/commitdiff
avformat/aviobuf: Don't check for overflow after it happened
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sun, 24 May 2020 01:14:00 +0000 (03:14 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Wed, 10 Jun 2020 23:18:54 +0000 (01:18 +0200)
If adding two ints overflows, it doesn't matter whether the result will
be stored in an unsigned or not; and checking afterwards does not make it
retroactively defined.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavformat/aviobuf.c

index 5ba5de01c6af02a72240102437c075fa077d1411..0e6125e161fafc8b15d7e74bed6925137684b258 100644 (file)
@@ -1287,7 +1287,7 @@ static int dyn_buf_write(void *opaque, uint8_t *buf, int buf_size)
     unsigned new_size, new_allocated_size;
 
     /* reallocate buffer if needed */
-    new_size = d->pos + buf_size;
+    new_size = (unsigned)d->pos + buf_size;
     new_allocated_size = d->allocated_size;
     if (new_size < d->pos || new_size > INT_MAX/2)
         return -1;