[llvm] 6b14c12 - Fix overflowing signed left shift, found by ubsan buildbot.

Richard Smith via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 3 12:51:52 PST 2021


Author: Richard Smith
Date: 2021-02-03T12:51:39-08:00
New Revision: 6b14c126884981bb4c2d767d2f2ea5f5864b5b39

URL: https://github.com/llvm/llvm-project/commit/6b14c126884981bb4c2d767d2f2ea5f5864b5b39
DIFF: https://github.com/llvm/llvm-project/commit/6b14c126884981bb4c2d767d2f2ea5f5864b5b39.diff

LOG: Fix overflowing signed left shift, found by ubsan buildbot.

Added: 
    

Modified: 
    llvm/include/llvm/Support/LEB128.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Support/LEB128.h b/llvm/include/llvm/Support/LEB128.h
index 9ba5f29b7b44..da43035a47d9 100644
--- a/llvm/include/llvm/Support/LEB128.h
+++ b/llvm/include/llvm/Support/LEB128.h
@@ -176,7 +176,7 @@ inline int64_t decodeSLEB128(const uint8_t *p, unsigned *n = nullptr,
       return 0;
     }
     Byte = *p;
-    int64_t Slice = Byte & 0x7f;
+    uint64_t Slice = Byte & 0x7f;
     if ((Shift >= 64 && Slice != (Value < 0 ? 0x7f : 0x00)) ||
         (Shift == 63 && Slice != 0 && Slice != 0x7f)) {
       if (error)


        


More information about the llvm-commits mailing list