Fix some undefined behavior (excessive shift of signed value) in r364253 detected by ubsan

llvm-svn: 364461
This commit is contained in:
David Blaikie 2019-06-26 19:18:50 +00:00
parent 806600987d
commit 730a95c88a
1 changed files with 1 additions and 1 deletions

View File

@ -176,7 +176,7 @@ inline int64_t decodeSLEB128(const uint8_t *p, unsigned *n = nullptr,
return 0;
}
Byte = *p++;
Value |= (int64_t(Byte & 0x7f) << Shift);
Value |= (uint64_t(Byte & 0x7f) << Shift);
Shift += 7;
} while (Byte >= 128);
// Sign extend negative numbers if needed.