From cee6c47a62c4d043c00eed860dc3900ad180b067 Mon Sep 17 00:00:00 2001 From: Jason Molenda <jmolenda@apple.com> Date: Sat, 9 Mar 2019 00:04:24 +0000 Subject: [PATCH] Add parens to force the order of operations in an expression trying to do "databuffer + offset" so that we don't overflow the uint64_t's we're using for addresses when working with high addresses. Found with clang's ubsan while doing darwin kernel debugging. <rdar://problem/48728940> llvm-svn: 355761 --- lldb/source/Target/Memory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Target/Memory.cpp b/lldb/source/Target/Memory.cpp index fac5e43c2865..7433317bf8ca 100644 --- a/lldb/source/Target/Memory.cpp +++ b/lldb/source/Target/Memory.cpp @@ -146,7 +146,7 @@ size_t MemoryCache::Read(addr_t addr, void *dst, size_t dst_len, } AddrRange chunk_range(pos->first, pos->second->GetByteSize()); if (chunk_range.Contains(read_range)) { - memcpy(dst, pos->second->GetBytes() + addr - chunk_range.GetRangeBase(), + memcpy(dst, pos->second->GetBytes() + (addr - chunk_range.GetRangeBase()), dst_len); return dst_len; }