diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-09-09 01:14:04 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-09-09 01:14:04 +0000 |
commit | 6d9bc278eff5aea217afcaa0c58a4ab74e592804 (patch) | |
tree | 7fba890a2b14f952ac5d0e1f8e273341091f7e2a /clang/lib/Basic/SourceManager.cpp | |
parent | 4b82f9c37ade37516eeae82d3599da84eb1551e7 (diff) | |
download | bcm5719-llvm-6d9bc278eff5aea217afcaa0c58a4ab74e592804.tar.gz bcm5719-llvm-6d9bc278eff5aea217afcaa0c58a4ab74e592804.zip |
Fix ownership of the MemoryBuffer in a FrontendInputFile.
This fixes a possible crash on certain kinds of corrupted AST file, but
checking in an AST file corrupted in just the right way will be a maintenance
nightmare because the format changes frequently.
llvm-svn: 312851
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index f0b53b4e48a..620f05c6377 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -409,15 +409,16 @@ SourceManager::getOrCreateContentCache(const FileEntry *FileEnt, } -/// createMemBufferContentCache - Create a new ContentCache for the specified -/// memory buffer. This does no caching. -const ContentCache *SourceManager::createMemBufferContentCache( - std::unique_ptr<llvm::MemoryBuffer> Buffer) { +/// Create a new ContentCache for the specified memory buffer. +/// This does no caching. +const ContentCache * +SourceManager::createMemBufferContentCache(llvm::MemoryBuffer *Buffer, + bool DoNotFree) { // Add a new ContentCache to the MemBufferInfos list and return it. ContentCache *Entry = ContentCacheAlloc.Allocate<ContentCache>(); new (Entry) ContentCache(); MemBufferInfos.push_back(Entry); - Entry->setBuffer(std::move(Buffer)); + Entry->replaceBuffer(Buffer, DoNotFree); return Entry; } |