[Lldb-commits] [lldb] r355761 - Add parens to force the order of operations in an expression trying

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 8 16:04:24 PST 2019


Author: jmolenda
Date: Fri Mar  8 16:04:24 2019
New Revision: 355761

URL: http://llvm.org/viewvc/llvm-project?rev=355761&view=rev
Log:
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> 


Modified:
    lldb/trunk/source/Target/Memory.cpp

Modified: lldb/trunk/source/Target/Memory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Memory.cpp?rev=355761&r1=355760&r2=355761&view=diff
==============================================================================
--- lldb/trunk/source/Target/Memory.cpp (original)
+++ lldb/trunk/source/Target/Memory.cpp Fri Mar  8 16:04:24 2019
@@ -146,7 +146,7 @@ size_t MemoryCache::Read(addr_t addr, vo
     }
     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;
     }




More information about the lldb-commits mailing list