[Support/StringSet] Fix memory leak when inserted key already exists.

llvm-svn: 166517
This commit is contained in:
Michael J. Spencer 2012-10-23 22:55:54 +00:00
parent 275e8834c1
commit 8e95113597
1 changed files with 7 additions and 2 deletions

View File

@ -29,8 +29,13 @@ namespace llvm {
assert(!InLang.empty()); assert(!InLang.empty());
const char *KeyStart = InLang.data(); const char *KeyStart = InLang.data();
const char *KeyEnd = KeyStart + InLang.size(); const char *KeyEnd = KeyStart + InLang.size();
return base::insert(llvm::StringMapEntry<char>:: llvm::StringMapEntry<char> *Entry = llvm::StringMapEntry<char>::
Create(KeyStart, KeyEnd, base::getAllocator(), '+')); Create(KeyStart, KeyEnd, base::getAllocator(), '+');
if (!base::insert(Entry)) {
Entry->Destroy(base::getAllocator());
return false;
}
return true;
} }
}; };
} }