summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/MemoryObject.cpp
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
commit5ff961c376224f767a3963149905fcd7233afeda (patch)
tree1629a364602518c320292de8cd3dc460ec3b98f0 /llvm/lib/Support/MemoryObject.cpp
parentd90c3c92d58a2757aab06b5d6d034a8f199c1ab5 (diff)
downloadbcm5719-llvm-5ff961c376224f767a3963149905fcd7233afeda.tar.gz
bcm5719-llvm-5ff961c376224f767a3963149905fcd7233afeda.zip
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. llvm-svn: 138705
Diffstat (limited to 'llvm/lib/Support/MemoryObject.cpp')
-rw-r--r--llvm/lib/Support/MemoryObject.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Support/MemoryObject.cpp b/llvm/lib/Support/MemoryObject.cpp
index 91e3ecd23a2..b20ab892381 100644
--- a/llvm/lib/Support/MemoryObject.cpp
+++ b/llvm/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;
OpenPOWER on IntegriCloud