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
This commit is contained in:
Argyrios Kyrtzidis 2011-12-10 01:38:26 +00:00
parent 8ca0c6408e
commit cc6107df08
1 changed files with 5 additions and 1 deletions

View 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();