[llvm] r240865 - Plug a leak introduced by r240848

Duncan P. N. Exon Smith dexonsmith at apple.com
Fri Jun 26 17:15:32 PDT 2015


Author: dexonsmith
Date: Fri Jun 26 19:15:32 2015
New Revision: 240865

URL: http://llvm.org/viewvc/llvm-project?rev=240865&view=rev
Log:
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

Modified:
    llvm/trunk/lib/IR/AsmWriter.cpp

Modified: llvm/trunk/lib/IR/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=240865&r1=240864&r2=240865&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)
+++ llvm/trunk/lib/IR/AsmWriter.cpp Fri Jun 26 19:15:32 2015
@@ -1941,8 +1941,11 @@ static void WriteAsOperandInternal(raw_o
                                    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





More information about the llvm-commits mailing list