Fix a nasty little use-after-free bug.

llvm-svn: 76779
This commit is contained in:
Eli Friedman 2009-07-22 20:29:16 +00:00
parent ed1c14ba65
commit 2729132ec3
1 changed files with 4 additions and 2 deletions

View File

@ -908,12 +908,14 @@ const ASTRecordLayout &ASTContext::getASTRecordLayout(const RecordDecl *D) {
assert(D && "Cannot get layout of forward declarations!");
// Look up this layout, if already laid out, return what we have.
const ASTRecordLayout *&Entry = ASTRecordLayouts[D];
// Note that we can't save a reference to the entry because this function
// is recursive.
const ASTRecordLayout *Entry = ASTRecordLayouts[D];
if (Entry) return *Entry;
const ASTRecordLayout *NewEntry =
ASTRecordLayoutBuilder::ComputeLayout(*this, D);
Entry = NewEntry;
ASTRecordLayouts[D] = NewEntry;
return *NewEntry;
}