forked from OSchip/llvm-project
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
This commit is contained in:
parent
005013c115
commit
eb7b27dab5
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue