[cfe-commits] r146308 - /cfe/trunk/lib/Basic/SourceManager.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Fri Dec 9 17:38:27 PST 2011
Author: akirtzidis
Date: Fri Dec 9 19:38:26 2011
New Revision: 146308
URL: http://llvm.org/viewvc/llvm-project?rev=146308&view=rev
Log:
In ContentCache::replaceBuffer, add sanity check to make sure that we do not free a buffer
and then continue using it. rdar://10359140.
Modified:
cfe/trunk/lib/Basic/SourceManager.cpp
Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=146308&r1=146307&r2=146308&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Fri Dec 9 19:38:26 2011
@@ -71,7 +71,11 @@
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();
More information about the cfe-commits
mailing list