diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2014-02-27 04:11:59 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2014-02-27 04:11:59 +0000 |
commit | 1b7ed91e44a8fdcb3217077204d60e7fc8d4561f (patch) | |
tree | 22268eb650ebd65e801631b863d68ea4a3d6bd74 /clang/lib/AST/ASTContext.cpp | |
parent | 08301dee468848e405d2a9c2ca08ad8af042be52 (diff) | |
download | bcm5719-llvm-1b7ed91e44a8fdcb3217077204d60e7fc8d4561f.tar.gz bcm5719-llvm-1b7ed91e44a8fdcb3217077204d60e7fc8d4561f.zip |
[ASTUnit] Fix use-after-free bug in ASTUnit::getMainBufferWithPrecompiledPreamble().
With r197755 we started reading the contents of buffer file entries, but the
buffers may point to ASTReader blobs that have been disposed.
Fix this by having the CompilerInstance object keep a reference to the ASTReader
as well as having the ASTContext keep reference to the ExternalASTSource.
This was very difficult to construct a test case for.
rdar://16149782
llvm-svn: 202346
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 46d0451017b..65bb024b2a9 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -791,8 +791,8 @@ void ASTContext::AddDeallocation(void (*Callback)(void*), void *Data) { } void -ASTContext::setExternalSource(OwningPtr<ExternalASTSource> &Source) { - ExternalSource.reset(Source.take()); +ASTContext::setExternalSource(IntrusiveRefCntPtr<ExternalASTSource> Source) { + ExternalSource = Source; } void ASTContext::PrintStats() const { @@ -846,7 +846,7 @@ void ASTContext::PrintStats() const { << NumImplicitDestructors << " implicit destructors created\n"; - if (ExternalSource.get()) { + if (ExternalSource) { llvm::errs() << "\n"; ExternalSource->PrintStats(); } |