[FFmpeg-cvslog] lavu/common.h: Fix UB in av_clip_uintp2_c()

Tomas Härdin git at videolan.org
Fri Jun 14 15:30:19 EEST 2024


ffmpeg | branch: master | Tomas Härdin <git at haerdin.se> | Thu May 16 16:37:58 2024 +0200| [3b9e457647a3c8554e32edf2e2effb11280ddda7] | committer: Tomas Härdin

lavu/common.h: Fix UB in av_clip_uintp2_c()

Found by value analysis

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

 libavutil/common.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/common.h b/libavutil/common.h
index 29cef74826..3b830daf30 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -279,8 +279,8 @@ static av_always_inline av_const int av_clip_intp2_c(int a, int p)
  */
 static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
 {
-    if (a & ~((1<<p) - 1)) return (~a) >> 31 & ((1<<p) - 1);
-    else                   return  a;
+    if (a & ~((1U<<p) - 1)) return (~a) >> 31 & ((1U<<p) - 1);
+    else                    return  a;
 }
 
 /**



More information about the ffmpeg-cvslog mailing list