From 846909e2ab0bd279ae2a8ec86074521f59c49eb3 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Fri, 5 Jun 2020 11:59:26 +0200 Subject: [PATCH] [lldb] Fix UBSan regression in GetSLEB128 It regressed recently by my: https://reviews.llvm.org/D81119 --- lldb/source/Utility/DataExtractor.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lldb/source/Utility/DataExtractor.cpp b/lldb/source/Utility/DataExtractor.cpp index 5f4abb8..023190b 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(1) << shift); + if (shift < size && (byte & 0x40)) { + // -(static_cast(1) << 63) errors on the negation with UBSan. + result |= -(static_cast(1) << shift); + } *offset_ptr += bytecount; return result; -- 2.7.4