Author: Jan Kratochvil Date: 2020-06-05T12:00:44+02:00 New Revision: 846909e2ab0bd279ae2a8ec86074521f59c49eb3
URL: https://github.com/llvm/llvm-project/commit/846909e2ab0bd279ae2a8ec86074521f59c49eb3 DIFF: https://github.com/llvm/llvm-project/commit/846909e2ab0bd279ae2a8ec86074521f59c49eb3.diff LOG: [lldb] Fix UBSan regression in GetSLEB128 It regressed recently by my: https://reviews.llvm.org/D81119 Added: Modified: lldb/source/Utility/DataExtractor.cpp Removed: ################################################################################ diff --git a/lldb/source/Utility/DataExtractor.cpp b/lldb/source/Utility/DataExtractor.cpp index 5f4abb82163e..023190b2ae91 100644 --- a/lldb/source/Utility/DataExtractor.cpp +++ b/lldb/source/Utility/DataExtractor.cpp @@ -930,8 +930,10 @@ int64_t DataExtractor::GetSLEB128(offset_t *offset_ptr) const { } // Sign bit of byte is 2nd high order bit (0x40) - if (shift < size && (byte & 0x40)) - result |= -(static_cast<int64_t>(1) << shift); + if (shift < size && (byte & 0x40)) { + // -(static_cast<int64_t>(1) << 63) errors on the negation with UBSan. + result |= -(static_cast<uint64_t>(1) << shift); + } *offset_ptr += bytecount; return result; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits