[FFmpeg-devel] [PATCH] lavc/libx264.c: Fix possible UB by NULL pointer LHS

Thilo Borgmann thilo.borgmann at mail.de
Thu Jun 16 18:58:09 EEST 2022


Hi,

the LHS pointer might be NULL so that += would be UB.

Thanks,
Thilo
-------------- next part --------------
From cfb7ce8092c34436fae3120645aa96fe082af4ea Mon Sep 17 00:00:00 2001
From: Michael Goulet <mgoulet at fb.com>
Date: Thu, 16 Jun 2022 17:52:56 +0200
Subject: [PATCH] lavc/libx264.c: Fix possible UB by NULL pointer LHS

It is UB to attempt to do pointer arithmetic on NULL pointer LHS, even if that pointer arithmetic ends up being "+= 0" (i.e. !!p == 0 if p == NULL).
---
 libavcodec/libx264.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 14177b3016..616d855067 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -940,7 +940,9 @@ static av_cold int X264_init(AVCodecContext *avctx)
                     return ret;
             }
             p= strchr(p, ':');
-            p+=!!p;
+            if (p) {
+                ++p;
+            }
         }
     }
 
-- 
2.20.1 (Apple Git-117)



More information about the ffmpeg-devel mailing list