summaryrefslogtreecommitdiff
path: root/lib/Support
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2011-08-27 07:45:46 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2011-08-27 07:45:46 +0000
commitf66f76c1a31539c65007a81fe28a1e06f638b4da (patch)
tree6240f6931e066efdf4a19236c432a9f88a59682f /lib/Support
parentd326d3b3ef314fcc61b55a75edad43aeb31a2b0d (diff)
downloadllvm-f66f76c1a31539c65007a81fe28a1e06f638b4da.tar.gz
llvm-f66f76c1a31539c65007a81fe28a1e06f638b4da.tar.bz2
llvm-f66f76c1a31539c65007a81fe28a1e06f638b4da.tar.xz
Report failure if there are less bytes than requested in a MemoryObject.
Before we just left the remaining bytes uninitialized. This is another step in making llvm valgrind-clean again. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138705 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/MemoryObject.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Support/MemoryObject.cpp b/lib/Support/MemoryObject.cpp
index 91e3ecd23a..b20ab89238 100644
--- a/lib/Support/MemoryObject.cpp
+++ b/lib/Support/MemoryObject.cpp
@@ -19,8 +19,11 @@ int MemoryObject::readBytes(uint64_t address,
uint64_t* copied) const {
uint64_t current = address;
uint64_t limit = getBase() + getExtent();
-
- while (current - address < size && current < limit) {
+
+ if (current + size > limit)
+ return -1;
+
+ while (current - address < size) {
if (readByte(current, &buf[(current - address)]))
return -1;