[Lldb-commits] [lldb] r177880 - Fixed a potential crash if layout for a structure

Sean Callanan scallanan at apple.com
Mon Mar 25 11:27:07 PDT 2013


Author: spyffe
Date: Mon Mar 25 13:27:07 2013
New Revision: 177880

URL: http://llvm.org/viewvc/llvm-project?rev=177880&view=rev
Log:
Fixed a potential crash if layout for a structure
went wrong and we tried to get layout information
that wasn't there.

<rdar://problem/13490170>

Modified:
    lldb/trunk/source/Expression/ClangASTSource.cpp

Modified: lldb/trunk/source/Expression/ClangASTSource.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=177880&r1=177879&r2=177880&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangASTSource.cpp (original)
+++ lldb/trunk/source/Expression/ClangASTSource.cpp Mon Mar 25 13:27:07 2013
@@ -1469,12 +1469,15 @@ ClangASTSource::layoutRecordType(const R
     
     const ASTRecordLayout &record_layout(origin_record->getASTContext().getASTRecordLayout(origin_record.decl));
     
-    int field_idx = 0;
+    int field_idx = 0, field_count = record_layout.getFieldCount();
     
     for (RecordDecl::field_iterator fi = origin_record->field_begin(), fe = origin_record->field_end();
          fi != fe;
          ++fi)
     {
+        if (field_idx >= field_count)
+            return false; // Layout didn't go well.  Bail out.
+        
         uint64_t field_offset = record_layout.getFieldOffset(field_idx);
         
         origin_field_offsets.insert(std::pair<const FieldDecl *, uint64_t>(*fi, field_offset));





More information about the lldb-commits mailing list