diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2009-07-22 20:29:16 +0000 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2009-07-22 20:29:16 +0000 |
| commit | 2729132ec35ca19ac5957179266e09bfb28d2fa3 (patch) | |
| tree | d0f613a8f6d342b122b16d33340b46a879ef0e5d /clang/lib | |
| parent | ed1c14ba652496d7167fad92f12cede40460f9ff (diff) | |
| download | bcm5719-llvm-2729132ec35ca19ac5957179266e09bfb28d2fa3.tar.gz bcm5719-llvm-2729132ec35ca19ac5957179266e09bfb28d2fa3.zip | |
Fix a nasty little use-after-free bug.
llvm-svn: 76779
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index d489d4e73fa..4490e9a3a9c 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -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; } |

