[PATCH libdrm 2/2] include: Avoid potentially infinite loop in log2_int().

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Paul Gofman <pgofman@xxxxxxxxxxxxxxx>
---
 util_math.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/util_math.h b/util_math.h
index e2fa95f5..f6bbe192 100644
--- a/util_math.h
+++ b/util_math.h
@@ -38,6 +38,9 @@ static inline unsigned log2_int(unsigned x)
     if (x < 2) {
         return 0;
     }
+    if (x & 0x80000000) {
+        return 31;
+    }
     for (l = 2; ; l++) {
         if ((unsigned)(1 << l) > x) {
             return l - 1;
-- 
2.28.0

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux