Plug a leak introduced by r240848

Apparently this obvious leak was never exercised before, but r240848
exposed it.  Plug it.

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/5075

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240865 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith 2015-06-27 00:15:32 +00:00
parent 50a38dc049
commit 4f95bcc836

View File

@ -1941,8 +1941,11 @@ static void WriteAsOperandInternal(raw_ostream &Out, const Metadata *MD,
SlotTracker *Machine, const Module *Context,
bool FromValue) {
if (const MDNode *N = dyn_cast<MDNode>(MD)) {
if (!Machine)
Machine = new SlotTracker(Context);
std::unique_ptr<SlotTracker> MachineStorage;
if (!Machine) {
MachineStorage = make_unique<SlotTracker>(Context);
Machine = MachineStorage.get();
}
int Slot = Machine->getMetadataSlot(N);
if (Slot == -1)
// Give the pointer value instead of "badref", since this comes up all