summaryrefslogtreecommitdiff
path: root/lib/Basic/SourceManager.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-12-10 01:38:26 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-12-10 01:38:26 +0000
commita4288c4aa05075cd45fd4de61d95ffe920fe6441 (patch)
tree4b9cace9d3b22b2aebdb499d8125f967ea361719 /lib/Basic/SourceManager.cpp
parent9aab9c4116bb3ea876d92d4af10bff7f4c451f24 (diff)
downloadclang-a4288c4aa05075cd45fd4de61d95ffe920fe6441.tar.gz
In ContentCache::replaceBuffer, add sanity check to make sure that we do not free a buffer
and then continue using it. rdar://10359140. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146308 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/SourceManager.cpp')
-rw-r--r--lib/Basic/SourceManager.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp
index 85fe474d66..18026dbdb7 100644
--- a/lib/Basic/SourceManager.cpp
+++ b/lib/Basic/SourceManager.cpp
@@ -71,7 +71,11 @@ unsigned ContentCache::getSize() const {
void ContentCache::replaceBuffer(const llvm::MemoryBuffer *B,
bool DoNotFree) {
- assert(B != Buffer.getPointer());
+ if (B == Buffer.getPointer()) {
+ assert(0 && "Replacing with the same buffer");
+ Buffer.setInt(DoNotFree? DoNotFreeFlag : 0);
+ return;
+ }
if (shouldFreeBuffer())
delete Buffer.getPointer();