]> granicus.if.org Git - clang/commitdiff
In ContentCache::replaceBuffer, add sanity check to make sure that we do not free...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 10 Dec 2011 01:38:26 +0000 (01:38 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 10 Dec 2011 01:38:26 +0000 (01:38 +0000)
and then continue using it. rdar://10359140.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146308 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/SourceManager.cpp

index 85fe474d6643e56d91c73296a6b7c9660eb9f6fa..18026dbdb7e061e01fec5e2f7360580e1ccfd5f1 100644 (file)
@@ -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();