[FFmpeg-cvslog] avformat/aviobuf: Don't check for overflow after it happened

Andreas Rheinhardt git at videolan.org
Fri Jul 3 03:11:17 EEST 2020


ffmpeg | branch: release/3.4 | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Sun May 24 03:14:00 2020 +0200| [6132ea3daf23fb03314f7fc00275f438a1cea07e] | committer: Andreas Rheinhardt

avformat/aviobuf: Don't check for overflow after it happened

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 at gmail.com>
(cherry picked from commit 28a078eded1c29985ed078b59d48ff59cf00394b)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6132ea3daf23fb03314f7fc00275f438a1cea07e
---

 libavformat/aviobuf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index c004e08bdf..2d31ab948f 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -1231,7 +1231,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;



More information about the ffmpeg-cvslog mailing list