Plug a leak introduced by r240848
[oota-llvm.git] / lib / IR / AsmWriter.cpp
index 7efb8e2bc7b672547955d0a564aff473eeb31fc2..fdfed9ee5adbcd82aa26d8d71da399d099e6e625 100644 (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