diff mbox series

[FFmpeg-devel,1/2] avcodec/avcodec: fix UB NULL+0

Message ID tencent_1514276BB8BD962ACD23A0354DA1CFC0D507@qq.com
State Accepted
Commit 36a56d3cc8dcc137df668e4f2c57d8d9f6310420
Headers show
Series [FFmpeg-devel,1/2] avcodec/avcodec: fix UB NULL+0 | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Zhao Zhili April 11, 2023, 5:49 p.m. UTC
From: Zhao Zhili <zhilizhao@tencent.com>

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

Comments

Zhao Zhili April 26, 2023, 12:49 p.m. UTC | #1
> On Apr 12, 2023, at 01:49, Zhao Zhili <quinkblack@foxmail.com> wrote:
> 
> From: Zhao Zhili <zhilizhao@tencent.com>
> 
> ---
> 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;
>     }
> -- 
> 2.25.1
> 

Will apply soon unless there is objection.
Zhao Zhili May 4, 2023, 7:01 a.m. UTC | #2
> On Apr 26, 2023, at 20:49, zhilizhao(赵志立) <quinkblack@foxmail.com> wrote:
> 
>> On Apr 12, 2023, at 01:49, Zhao Zhili <quinkblack@foxmail.com> wrote:
>> 
>> From: Zhao Zhili <zhilizhao@tencent.com>
>> 
>> ---
>> 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;
>>    }
>> -- 
>> 2.25.1
>> 
> 
> Will apply soon unless there is objection.

Applied as 36a56d3c and 0d40711f.

> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

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;
     }