[cfe-commits] r76779 - /cfe/trunk/lib/AST/ASTContext.cpp
Eli Friedman
eli.friedman at gmail.com
Wed Jul 22 13:29:16 PDT 2009
Author: efriedma
Date: Wed Jul 22 15:29:16 2009
New Revision: 76779
URL: http://llvm.org/viewvc/llvm-project?rev=76779&view=rev
Log:
Fix a nasty little use-after-free bug.
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=76779&r1=76778&r2=76779&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Jul 22 15:29:16 2009
@@ -908,12 +908,14 @@
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;
}
More information about the cfe-commits
mailing list