Hardened against reads in the IRMemoryMap that
exceed the bounds of the backing memory.

<rdar://problem/16088322>

llvm-svn: 202899
diff --git a/lldb/source/Expression/IRMemoryMap.cpp b/lldb/source/Expression/IRMemoryMap.cpp
index 53f74ae..f927e8b 100644
--- a/lldb/source/Expression/IRMemoryMap.cpp
+++ b/lldb/source/Expression/IRMemoryMap.cpp
@@ -576,6 +576,13 @@
     
     uint64_t offset = process_address - allocation.m_process_start;
     
+    if (offset > allocation.m_size)
+    {
+        error.SetErrorToGenericError();
+        error.SetErrorString("Couldn't read: data is not in the allocation");
+        return;
+    }
+    
     lldb::ProcessSP process_sp;
     
     switch (allocation.m_policy)
@@ -591,6 +598,13 @@
             error.SetErrorString("Couldn't read: data buffer is empty");
             return;
         }
+        if (allocation.m_data.GetByteSize() < offset + size)
+        {
+            error.SetErrorToGenericError();
+            error.SetErrorString("Couldn't read: not enough underlying data");
+            return;
+        }
+
         ::memcpy (bytes, allocation.m_data.GetBytes() + offset, size);
         break;
     case eAllocationPolicyMirror: