summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2013-03-25 18:27:07 +0000
committerSean Callanan <scallanan@apple.com>2013-03-25 18:27:07 +0000
commiteb7b27dab587de22bcfb3a84f40b25b77038dc38 (patch)
tree4ca6e36e072adac0484d6b98e8897c0673543734
parent005013c115a42378b6869f23734d14d45129a99b (diff)
downloadbcm5719-llvm-eb7b27dab587de22bcfb3a84f40b25b77038dc38.tar.gz
bcm5719-llvm-eb7b27dab587de22bcfb3a84f40b25b77038dc38.zip
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> llvm-svn: 177880
-rw-r--r--lldb/source/Expression/ClangASTSource.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/lldb/source/Expression/ClangASTSource.cpp b/lldb/source/Expression/ClangASTSource.cpp
index 419988fa1eb..a508c48d449 100644
--- a/lldb/source/Expression/ClangASTSource.cpp
+++ b/lldb/source/Expression/ClangASTSource.cpp
@@ -1469,12 +1469,15 @@ ClangASTSource::layoutRecordType(const RecordDecl *record,
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));
OpenPOWER on IntegriCloud