From cc6107df087e3294bde69584aaeaae77adeac2d3 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Sat, 10 Dec 2011 01:38:26 +0000 Subject: In ContentCache::replaceBuffer, add sanity check to make sure that we do not free a buffer and then continue using it. rdar://10359140. llvm-svn: 146308 --- clang/lib/Basic/SourceManager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'clang/lib/Basic/SourceManager.cpp') diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 85fe474d664..18026dbdb7e 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/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(); -- cgit v1.2.3