From c840b5c6e8f0c4d5f3ea11d5a2e8b94cae5ada75 Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Thu, 27 Apr 2017 02:09:44 +0000 Subject: [PATCH] [Support] Fix overflow in SLEB128 decoding. decodeULEB128 was fixed in r216268, but decodeSLEB128 always had the same issue, which is now exposed in r301369. llvm-svn: 301510 --- include/llvm/Support/LEB128.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/llvm/Support/LEB128.h b/include/llvm/Support/LEB128.h index a2bcef81bee..29640db6921 100644 --- a/include/llvm/Support/LEB128.h +++ b/include/llvm/Support/LEB128.h @@ -160,7 +160,7 @@ inline int64_t decodeSLEB128(const uint8_t *p, unsigned *n = nullptr, return 0; } Byte = *p++; - Value |= ((Byte & 0x7f) << Shift); + Value |= (int64_t(Byte & 0x7f) << Shift); Shift += 7; } while (Byte >= 128); // Sign extend negative numbers.