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
This commit is contained in:
Jason Molenda 2019-03-09 00:04:24 +00:00
parent 411210838d
commit cee6c47a62
1 changed files with 1 additions and 1 deletions

View File

@ -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;
}