finish encoding all of the interesting details of intrinsics. Now intrinsics
[oota-llvm.git] / lib / Support / MemoryObject.cpp
index 91e3ecd23a2e7f807c6840a43d7215b8c03e4419..b20ab8923813215845aa1a517505b95ddc319cd2 100644 (file)
@@ -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;