[FFmpeg-cvslog] avcodec/avcodec: fix UB NULL+0

Zhao Zhili git at videolan.org
Thu May 4 09:59:02 EEST 2023


ffmpeg | branch: master | Zhao Zhili <zhilizhao at tencent.com> | Wed Apr 12 01:49:26 2023 +0800| [36a56d3cc8dcc137df668e4f2c57d8d9f6310420] | committer: Zhao Zhili

avcodec/avcodec: fix UB NULL+0

Signed-off-by: Zhao Zhili <zhilizhao at tencent.com>

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

 libavcodec/avcodec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index fb1362290f..5a96899d50 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -44,10 +44,11 @@
 
 int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size)
 {
-    int i;
+    size_t i;
 
     for (i = 0; i < count; i++) {
-        int r = func(c, (char *)arg + i * size);
+        size_t offset = i * size;
+        int r = func(c, FF_PTR_ADD((char *)arg, offset));
         if (ret)
             ret[i] = r;
     }



More information about the ffmpeg-cvslog mailing list