From: Duncan P. N. Exon Smith Date: Sat, 27 Jun 2015 00:15:32 +0000 (+0000) Subject: Plug a leak introduced by r240848 X-Git-Tag: llvmorg-3.7.0-rc1~1330 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f8b3ad611d7b51d0a24603fca497dbb553c38a5b;p=platform%2Fupstream%2Fllvm.git 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 llvm-svn: 240865 --- diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index 7efb8e2..fdfed9e 100644 --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -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(MD)) { - if (!Machine) - Machine = new SlotTracker(Context); + std::unique_ptr MachineStorage; + if (!Machine) { + MachineStorage = make_unique(Context); + Machine = MachineStorage.get(); + } int Slot = Machine->getMetadataSlot(N); if (Slot == -1) // Give the pointer value instead of "badref", since this comes up all