[Lldb-commits] [lldb] r151066 - /lldb/trunk/source/Symbol/ObjectFile.cpp

Greg Clayton gclayton at apple.com
Tue Feb 21 09:34:25 PST 2012


Author: gclayton
Date: Tue Feb 21 11:34:25 2012
New Revision: 151066

URL: http://llvm.org/viewvc/llvm-project?rev=151066&view=rev
Log:
Fixed an issue where empty sections or zero filled sections could return
incorrect values and also fire an assertion.


Modified:
    lldb/trunk/source/Symbol/ObjectFile.cpp

Modified: lldb/trunk/source/Symbol/ObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ObjectFile.cpp?rev=151066&r1=151065&r2=151066&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ObjectFile.cpp (original)
+++ lldb/trunk/source/Symbol/ObjectFile.cpp Tue Feb 21 11:34:25 2012
@@ -393,7 +393,15 @@
     }
     else
     {
-        return CopyData (section->GetFileOffset() + section_offset, dst_len, dst);
+        const uint64_t section_file_size = section->GetFileSize();
+        if (section_offset < section_file_size)
+        {
+            const uint64_t section_bytes_left = section_file_size - section_offset;
+            uint64_t section_dst_len = dst_len;
+            if (section_dst_len > section_bytes_left)
+                section_dst_len = section_bytes_left;
+            return CopyData (section->GetFileOffset() + section_offset, section_dst_len, dst);
+        }
     }
     return 0;
 }





More information about the lldb-commits mailing list